Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/**2 * @license3 * MIT License4 * 5 * Copyright (c) 2014-present, Lee Byron and other contributors.6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy8 * of this software and associated documentation files (the "Software"), to deal9 * in the Software without restriction, including without limitation the rights10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell11 * copies of the Software, and to permit persons to whom the Software is12 * furnished to do so, subject to the following conditions:13 * 14 * The above copyright notice and this permission notice shall be included in all15 * copies or substantial portions of the Software.16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23 * SOFTWARE.24 */25var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';26/**27 * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.28 *29 * ```js30 * import { isIndexed, Map, List, Stack, Set } from 'immutable';31 *32 * isIndexed([]); // false33 * isIndexed({}); // false34 * isIndexed(Map()); // false35 * isIndexed(List()); // true36 * isIndexed(Stack()); // true37 * isIndexed(Set()); // false38 * ```39 */40function isIndexed(maybeIndexed) {41 return Boolean(maybeIndexed &&42 // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed`43 maybeIndexed[IS_INDEXED_SYMBOL]);44}45 46var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';47/**48 * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.49 *50 * ```js51 * import { isKeyed, Map, List, Stack } from 'immutable';52 *53 * isKeyed([]); // false54 * isKeyed({}); // false55 * isKeyed(Map()); // true56 * isKeyed(List()); // false57 * isKeyed(Stack()); // false58 * ```59 */60function isKeyed(maybeKeyed) {61 return Boolean(maybeKeyed &&62 // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed`63 maybeKeyed[IS_KEYED_SYMBOL]);64}65 66/**67 * True if `maybeAssociative` is either a Keyed or Indexed Collection.68 *69 * ```js70 * import { isAssociative, Map, List, Stack, Set } from 'immutable';71 *72 * isAssociative([]); // false73 * isAssociative({}); // false74 * isAssociative(Map()); // true75 * isAssociative(List()); // true76 * isAssociative(Stack()); // true77 * isAssociative(Set()); // false78 * ```79 */80function isAssociative(maybeAssociative) {81 return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);82}83 84// Note: value is unchanged to not break immutable-devtools.85var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';86/**87 * True if `maybeCollection` is a Collection, or any of its subclasses.88 *89 * ```js90 * import { isCollection, Map, List, Stack } from 'immutable';91 *92 * isCollection([]); // false93 * isCollection({}); // false94 * isCollection(Map()); // true95 * isCollection(List()); // true96 * isCollection(Stack()); // true97 * ```98 */99function isCollection(maybeCollection) {100 return Boolean(maybeCollection &&101 // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection`102 maybeCollection[IS_COLLECTION_SYMBOL]);103}104 105var Collection = function Collection(value) {106 // eslint-disable-next-line no-constructor-return107 return isCollection(value) ? value : Seq(value);108};109 110var KeyedCollection = /*@__PURE__*/(function (Collection) {111 function KeyedCollection(value) {112 // eslint-disable-next-line no-constructor-return113 return isKeyed(value) ? value : KeyedSeq(value);114 }115 116 if ( Collection ) KeyedCollection.__proto__ = Collection;117 KeyedCollection.prototype = Object.create( Collection && Collection.prototype );118 KeyedCollection.prototype.constructor = KeyedCollection;119 120 return KeyedCollection;121}(Collection));122 123var IndexedCollection = /*@__PURE__*/(function (Collection) {124 function IndexedCollection(value) {125 // eslint-disable-next-line no-constructor-return126 return isIndexed(value) ? value : IndexedSeq(value);127 }128 129 if ( Collection ) IndexedCollection.__proto__ = Collection;130 IndexedCollection.prototype = Object.create( Collection && Collection.prototype );131 IndexedCollection.prototype.constructor = IndexedCollection;132 133 return IndexedCollection;134}(Collection));135 136var SetCollection = /*@__PURE__*/(function (Collection) {137 function SetCollection(value) {138 // eslint-disable-next-line no-constructor-return139 return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);140 }141 142 if ( Collection ) SetCollection.__proto__ = Collection;143 SetCollection.prototype = Object.create( Collection && Collection.prototype );144 SetCollection.prototype.constructor = SetCollection;145 146 return SetCollection;147}(Collection));148 149Collection.Keyed = KeyedCollection;150Collection.Indexed = IndexedCollection;151Collection.Set = SetCollection;152 153var ITERATE_KEYS = 0;154var ITERATE_VALUES = 1;155var ITERATE_ENTRIES = 2;156// TODO Symbol is widely available in modern JavaScript environments, clean this157var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;158var FAUX_ITERATOR_SYMBOL = '@@iterator';159var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;160// @ts-expect-error: properties are not supported in buble161var Iterator = function Iterator(next) {162 // @ts-expect-error: properties are not supported in buble163 this.next = next;164};165Iterator.prototype.toString = function toString () {166 return '[Iterator]';167};168// @ts-expect-error: static properties are not supported in buble169Iterator.KEYS = ITERATE_KEYS;170// @ts-expect-error: static properties are not supported in buble171Iterator.VALUES = ITERATE_VALUES;172// @ts-expect-error: static properties are not supported in buble173Iterator.ENTRIES = ITERATE_ENTRIES;174// @ts-expect-error: properties are not supported in buble175Iterator.prototype.inspect = Iterator.prototype.toSource = function () {176 return this.toString();177};178// @ts-expect-error don't know how to type this179Iterator.prototype[ITERATOR_SYMBOL] = function () {180 return this;181};182function iteratorValue(type, k, v, iteratorResult) {183 var value = type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v];184 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here185 iteratorResult186 ? (iteratorResult.value = value)187 : (iteratorResult = {188 // @ts-expect-error ensure value is not undefined189 value: value,190 done: false,191 });192 return iteratorResult;193}194function iteratorDone() {195 return { value: undefined, done: true };196}197function hasIterator(maybeIterable) {198 if (Array.isArray(maybeIterable)) {199 // IE11 trick as it does not support `Symbol.iterator`200 return true;201 }202 return !!getIteratorFn(maybeIterable);203}204function isIterator(maybeIterator) {205 return !!(maybeIterator &&206 // @ts-expect-error: maybeIterator is typed as `{}`207 typeof maybeIterator.next === 'function');208}209function getIterator(iterable) {210 var iteratorFn = getIteratorFn(iterable);211 return iteratorFn && iteratorFn.call(iterable);212}213function getIteratorFn(iterable) {214 var iteratorFn = iterable &&215 // @ts-expect-error: maybeIterator is typed as `{}`216 ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||217 // @ts-expect-error: maybeIterator is typed as `{}`218 iterable[FAUX_ITERATOR_SYMBOL]);219 if (typeof iteratorFn === 'function') {220 return iteratorFn;221 }222}223function isEntriesIterable(maybeIterable) {224 var iteratorFn = getIteratorFn(maybeIterable);225 // @ts-expect-error: maybeIterator is typed as `{}`226 return iteratorFn && iteratorFn === maybeIterable.entries;227}228function isKeysIterable(maybeIterable) {229 var iteratorFn = getIteratorFn(maybeIterable);230 // @ts-expect-error: maybeIterator is typed as `{}`231 return iteratorFn && iteratorFn === maybeIterable.keys;232}233 234// Used for setting prototype methods that IE8 chokes on.235var DELETE = 'delete';236// Constants describing the size of trie nodes.237var SHIFT = 5; // Resulted in best performance after ______?238var SIZE = 1 << SHIFT;239var MASK = SIZE - 1;240// A consistent shared value representing "not set" which equals nothing other241// than itself, and nothing that could be provided externally.242var NOT_SET = {};243// Boolean references, Rough equivalent of `bool &`.244function MakeRef() {245 return { value: false };246}247function SetRef(ref) {248 if (ref) {249 ref.value = true;250 }251}252// A function which returns a value representing an "owner" for transient writes253// to tries. The return value will only ever equal itself, and will not equal254// the return of any subsequent call of this function.255function OwnerID() { }256function ensureSize(iter) {257 // @ts-expect-error size should exists on Collection258 if (iter.size === undefined) {259 // @ts-expect-error size should exists on Collection, __iterate does exist on Collection260 iter.size = iter.__iterate(returnTrue);261 }262 // @ts-expect-error size should exists on Collection263 return iter.size;264}265function wrapIndex(iter, index) {266 // This implements "is array index" which the ECMAString spec defines as:267 //268 // A String property name P is an array index if and only if269 // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal270 // to 2^32−1.271 //272 // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects273 if (typeof index !== 'number') {274 var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32275 if ('' + uint32Index !== index || uint32Index === 4294967295) {276 return NaN;277 }278 index = uint32Index;279 }280 return index < 0 ? ensureSize(iter) + index : index;281}282function returnTrue() {283 return true;284}285function wholeSlice(begin, end, size) {286 return (((begin === 0 && !isNeg(begin)) ||287 (size !== undefined && begin <= -size)) &&288 (end === undefined || (size !== undefined && end >= size)));289}290function resolveBegin(begin, size) {291 return resolveIndex(begin, size, 0);292}293function resolveEnd(end, size) {294 return resolveIndex(end, size, size);295}296function resolveIndex(index, size, defaultIndex) {297 // Sanitize indices using this shorthand for ToInt32(argument)298 // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32299 return index === undefined300 ? defaultIndex301 : isNeg(index)302 ? size === Infinity303 ? size304 : Math.max(0, size + index) | 0305 : size === undefined || size === index306 ? index307 : Math.min(size, index) | 0;308}309function isNeg(value) {310 // Account for -0 which is negative, but not less than 0.311 return value < 0 || (value === 0 && 1 / value === -Infinity);312}313 314var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';315/**316 * True if `maybeRecord` is a Record.317 */318function isRecord(maybeRecord) {319 return Boolean(maybeRecord &&320 // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord`321 maybeRecord[IS_RECORD_SYMBOL]);322}323 324/**325 * True if `maybeImmutable` is an Immutable Collection or Record.326 *327 * Note: Still returns true even if the collections is within a `withMutations()`.328 *329 * ```js330 * import { isImmutable, Map, List, Stack } from 'immutable';331 * isImmutable([]); // false332 * isImmutable({}); // false333 * isImmutable(Map()); // true334 * isImmutable(List()); // true335 * isImmutable(Stack()); // true336 * isImmutable(Map().asMutable()); // true337 * ```338 */339function isImmutable(maybeImmutable) {340 return isCollection(maybeImmutable) || isRecord(maybeImmutable);341}342 343var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';344function isOrdered(maybeOrdered) {345 return Boolean(maybeOrdered &&346 // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered`347 maybeOrdered[IS_ORDERED_SYMBOL]);348}349 350var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';351/**352 * True if `maybeSeq` is a Seq.353 */354function isSeq(maybeSeq) {355 return Boolean(maybeSeq &&356 // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq`357 maybeSeq[IS_SEQ_SYMBOL]);358}359 360var hasOwnProperty = Object.prototype.hasOwnProperty;361 362function isArrayLike(value) {363 if (Array.isArray(value) || typeof value === 'string') {364 return true;365 }366 // @ts-expect-error "Type 'unknown' is not assignable to type 'boolean'" : convert to Boolean367 return (value &&368 typeof value === 'object' &&369 // @ts-expect-error check that `'length' in value &&`370 Number.isInteger(value.length) &&371 // @ts-expect-error check that `'length' in value &&`372 value.length >= 0 &&373 // @ts-expect-error check that `'length' in value &&`374 (value.length === 0375 ? // Only {length: 0} is considered Array-like.376 Object.keys(value).length === 1377 : // An object is only Array-like if it has a property where the last value378 // in the array-like may be found (which could be undefined).379 // @ts-expect-error check that `'length' in value &&`380 value.hasOwnProperty(value.length - 1)));381}382 383var Seq = /*@__PURE__*/(function (Collection) {384 function Seq(value) {385 // eslint-disable-next-line no-constructor-return386 return value === undefined || value === null387 ? emptySequence()388 : isImmutable(value)389 ? value.toSeq()390 : seqFromValue(value);391 }392 393 if ( Collection ) Seq.__proto__ = Collection;394 Seq.prototype = Object.create( Collection && Collection.prototype );395 Seq.prototype.constructor = Seq;396 397 Seq.prototype.toSeq = function toSeq () {398 return this;399 };400 401 Seq.prototype.toString = function toString () {402 return this.__toString('Seq {', '}');403 };404 405 Seq.prototype.cacheResult = function cacheResult () {406 if (!this._cache && this.__iterateUncached) {407 this._cache = this.entrySeq().toArray();408 this.size = this._cache.length;409 }410 return this;411 };412 413 // abstract __iterateUncached(fn, reverse)414 415 Seq.prototype.__iterate = function __iterate (fn, reverse) {416 var cache = this._cache;417 if (cache) {418 var size = cache.length;419 var i = 0;420 while (i !== size) {421 var entry = cache[reverse ? size - ++i : i++];422 if (fn(entry[1], entry[0], this) === false) {423 break;424 }425 }426 return i;427 }428 return this.__iterateUncached(fn, reverse);429 };430 431 // abstract __iteratorUncached(type, reverse)432 433 Seq.prototype.__iterator = function __iterator (type, reverse) {434 var cache = this._cache;435 if (cache) {436 var size = cache.length;437 var i = 0;438 return new Iterator(function () {439 if (i === size) {440 return iteratorDone();441 }442 var entry = cache[reverse ? size - ++i : i++];443 return iteratorValue(type, entry[0], entry[1]);444 });445 }446 return this.__iteratorUncached(type, reverse);447 };448 449 return Seq;450}(Collection));451 452var KeyedSeq = /*@__PURE__*/(function (Seq) {453 function KeyedSeq(value) {454 // eslint-disable-next-line no-constructor-return455 return value === undefined || value === null456 ? emptySequence().toKeyedSeq()457 : isCollection(value)458 ? isKeyed(value)459 ? value.toSeq()460 : value.fromEntrySeq()461 : isRecord(value)462 ? value.toSeq()463 : keyedSeqFromValue(value);464 }465 466 if ( Seq ) KeyedSeq.__proto__ = Seq;467 KeyedSeq.prototype = Object.create( Seq && Seq.prototype );468 KeyedSeq.prototype.constructor = KeyedSeq;469 470 KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {471 return this;472 };473 474 return KeyedSeq;475}(Seq));476 477var IndexedSeq = /*@__PURE__*/(function (Seq) {478 function IndexedSeq(value) {479 // eslint-disable-next-line no-constructor-return480 return value === undefined || value === null481 ? emptySequence()482 : isCollection(value)483 ? isKeyed(value)484 ? value.entrySeq()485 : value.toIndexedSeq()486 : isRecord(value)487 ? value.toSeq().entrySeq()488 : indexedSeqFromValue(value);489 }490 491 if ( Seq ) IndexedSeq.__proto__ = Seq;492 IndexedSeq.prototype = Object.create( Seq && Seq.prototype );493 IndexedSeq.prototype.constructor = IndexedSeq;494 495 IndexedSeq.of = function of (/*...values*/) {496 return IndexedSeq(arguments);497 };498 499 IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {500 return this;501 };502 503 IndexedSeq.prototype.toString = function toString () {504 return this.__toString('Seq [', ']');505 };506 507 return IndexedSeq;508}(Seq));509 510var SetSeq = /*@__PURE__*/(function (Seq) {511 function SetSeq(value) {512 // eslint-disable-next-line no-constructor-return513 return (514 isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)515 ).toSetSeq();516 }517 518 if ( Seq ) SetSeq.__proto__ = Seq;519 SetSeq.prototype = Object.create( Seq && Seq.prototype );520 SetSeq.prototype.constructor = SetSeq;521 522 SetSeq.of = function of (/*...values*/) {523 return SetSeq(arguments);524 };525 526 SetSeq.prototype.toSetSeq = function toSetSeq () {527 return this;528 };529 530 return SetSeq;531}(Seq));532 533Seq.isSeq = isSeq;534Seq.Keyed = KeyedSeq;535Seq.Set = SetSeq;536Seq.Indexed = IndexedSeq;537 538Seq.prototype[IS_SEQ_SYMBOL] = true;539 540// #pragma Root Sequences541 542var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {543 function ArraySeq(array) {544 this._array = array;545 this.size = array.length;546 }547 548 if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;549 ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );550 ArraySeq.prototype.constructor = ArraySeq;551 552 ArraySeq.prototype.get = function get (index, notSetValue) {553 return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;554 };555 556 ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {557 var array = this._array;558 var size = array.length;559 var i = 0;560 while (i !== size) {561 var ii = reverse ? size - ++i : i++;562 if (fn(array[ii], ii, this) === false) {563 break;564 }565 }566 return i;567 };568 569 ArraySeq.prototype.__iterator = function __iterator (type, reverse) {570 var array = this._array;571 var size = array.length;572 var i = 0;573 return new Iterator(function () {574 if (i === size) {575 return iteratorDone();576 }577 var ii = reverse ? size - ++i : i++;578 return iteratorValue(type, ii, array[ii]);579 });580 };581 582 return ArraySeq;583}(IndexedSeq));584 585var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {586 function ObjectSeq(object) {587 var keys = Object.keys(object).concat(588 Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []589 );590 this._object = object;591 this._keys = keys;592 this.size = keys.length;593 }594 595 if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;596 ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );597 ObjectSeq.prototype.constructor = ObjectSeq;598 599 ObjectSeq.prototype.get = function get (key, notSetValue) {600 if (notSetValue !== undefined && !this.has(key)) {601 return notSetValue;602 }603 return this._object[key];604 };605 606 ObjectSeq.prototype.has = function has (key) {607 return hasOwnProperty.call(this._object, key);608 };609 610 ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {611 var object = this._object;612 var keys = this._keys;613 var size = keys.length;614 var i = 0;615 while (i !== size) {616 var key = keys[reverse ? size - ++i : i++];617 if (fn(object[key], key, this) === false) {618 break;619 }620 }621 return i;622 };623 624 ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {625 var object = this._object;626 var keys = this._keys;627 var size = keys.length;628 var i = 0;629 return new Iterator(function () {630 if (i === size) {631 return iteratorDone();632 }633 var key = keys[reverse ? size - ++i : i++];634 return iteratorValue(type, key, object[key]);635 });636 };637 638 return ObjectSeq;639}(KeyedSeq));640ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;641 642var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {643 function CollectionSeq(collection) {644 this._collection = collection;645 this.size = collection.length || collection.size;646 }647 648 if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;649 CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );650 CollectionSeq.prototype.constructor = CollectionSeq;651 652 CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {653 if (reverse) {654 return this.cacheResult().__iterate(fn, reverse);655 }656 var collection = this._collection;657 var iterator = getIterator(collection);658 var iterations = 0;659 if (isIterator(iterator)) {660 var step;661 while (!(step = iterator.next()).done) {662 if (fn(step.value, iterations++, this) === false) {663 break;664 }665 }666 }667 return iterations;668 };669 670 CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {671 if (reverse) {672 return this.cacheResult().__iterator(type, reverse);673 }674 var collection = this._collection;675 var iterator = getIterator(collection);676 if (!isIterator(iterator)) {677 return new Iterator(iteratorDone);678 }679 var iterations = 0;680 return new Iterator(function () {681 var step = iterator.next();682 return step.done ? step : iteratorValue(type, iterations++, step.value);683 });684 };685 686 return CollectionSeq;687}(IndexedSeq));688 689// # pragma Helper functions690 691var EMPTY_SEQ;692 693function emptySequence() {694 return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));695}696 697function keyedSeqFromValue(value) {698 var seq = maybeIndexedSeqFromValue(value);699 if (seq) {700 return seq.fromEntrySeq();701 }702 if (typeof value === 'object') {703 return new ObjectSeq(value);704 }705 throw new TypeError(706 'Expected Array or collection object of [k, v] entries, or keyed object: ' +707 value708 );709}710 711function indexedSeqFromValue(value) {712 var seq = maybeIndexedSeqFromValue(value);713 if (seq) {714 return seq;715 }716 throw new TypeError(717 'Expected Array or collection object of values: ' + value718 );719}720 721function seqFromValue(value) {722 var seq = maybeIndexedSeqFromValue(value);723 if (seq) {724 return isEntriesIterable(value)725 ? seq.fromEntrySeq()726 : isKeysIterable(value)727 ? seq.toSetSeq()728 : seq;729 }730 if (typeof value === 'object') {731 return new ObjectSeq(value);732 }733 throw new TypeError(734 'Expected Array or collection object of values, or keyed object: ' + value735 );736}737 738function maybeIndexedSeqFromValue(value) {739 return isArrayLike(value)740 ? new ArraySeq(value)741 : hasIterator(value)742 ? new CollectionSeq(value)743 : undefined;744}745 746function asImmutable() {747 return this.__ensureOwner();748}749 750function asMutable() {751 return this.__ownerID ? this : this.__ensureOwner(new OwnerID());752}753 754// TODO remove in v6 as Math.imul is widely available now: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul755var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2756 ? Math.imul757 : function imul(a, b) {758 a |= 0; // int759 b |= 0; // int760 var c = a & 0xffff;761 var d = b & 0xffff;762 // Shift by 0 fixes the sign on the high part.763 return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int764 };765// v8 has an optimization for storing 31-bit signed numbers.766// Values which have either 00 or 11 as the high order bits qualify.767// This function drops the highest order bit in a signed number, maintaining768// the sign bit.769function smi(i32) {770 return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);771}772 773var defaultValueOf = Object.prototype.valueOf;774function hash(o) {775 // eslint-disable-next-line eqeqeq776 if (o == null) {777 return hashNullish(o);778 }779 // @ts-expect-error don't care about object beeing typed as `{}` here780 if (typeof o.hashCode === 'function') {781 // Drop any high bits from accidentally long hash codes.782 // @ts-expect-error don't care about object beeing typed as `{}` here783 return smi(o.hashCode(o));784 }785 var v = valueOf(o);786 // eslint-disable-next-line eqeqeq787 if (v == null) {788 return hashNullish(v);789 }790 switch (typeof v) {791 case 'boolean':792 // The hash values for built-in constants are a 1 value for each 5-byte793 // shift region expect for the first, which encodes the value. This794 // reduces the odds of a hash collision for these common values.795 return v ? 0x42108421 : 0x42108420;796 case 'number':797 return hashNumber(v);798 case 'string':799 return v.length > STRING_HASH_CACHE_MIN_STRLEN800 ? cachedHashString(v)801 : hashString(v);802 case 'object':803 case 'function':804 return hashJSObj(v);805 case 'symbol':806 return hashSymbol(v);807 default:808 if (typeof v.toString === 'function') {809 return hashString(v.toString());810 }811 throw new Error('Value type ' + typeof v + ' cannot be hashed.');812 }813}814function hashNullish(nullish) {815 return nullish === null ? 0x42108422 : /* undefined */ 0x42108423;816}817// Compress arbitrarily large numbers into smi hashes.818function hashNumber(n) {819 if (n !== n || n === Infinity) {820 return 0;821 }822 var hash = n | 0;823 if (hash !== n) {824 hash ^= n * 0xffffffff;825 }826 while (n > 0xffffffff) {827 n /= 0xffffffff;828 hash ^= n;829 }830 return smi(hash);831}832function cachedHashString(string) {833 var hashed = stringHashCache[string];834 if (hashed === undefined) {835 hashed = hashString(string);836 if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {837 STRING_HASH_CACHE_SIZE = 0;838 stringHashCache = {};839 }840 STRING_HASH_CACHE_SIZE++;841 stringHashCache[string] = hashed;842 }843 return hashed;844}845// http://jsperf.com/hashing-strings846function hashString(string) {847 // This is the hash from JVM848 // The hash code for a string is computed as849 // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],850 // where s[i] is the ith character of the string and n is the length of851 // the string. We "mod" the result to make it between 0 (inclusive) and 2^31852 // (exclusive) by dropping high bits.853 var hashed = 0;854 for (var ii = 0; ii < string.length; ii++) {855 hashed = (31 * hashed + string.charCodeAt(ii)) | 0;856 }857 return smi(hashed);858}859// Per-process seed for the secondary collision hash. Never exposed nor860// serialized, so the public `hash()` stays deterministic. An odd base in861// [3, 2^20) keeps `base * h` exact as a double (no `Math.imul`).862var COLLISION_HASH_BASE = ((Math.random() * 0x100000) | 1) % 0x100000 || 0x9e37;863// Secondary hash to index entries within a `HashCollisionNode`, where every key864// shares the same primary `hash()`. Using a different, seeded base scatters865// crafted collision families (e.g. "Aa"/"BB", which only collide under base 31)866// that an attacker cannot precompute without the seed. It only narrows867// candidates — `is()` still decides equality — so non-string keys can safely868// fall back to the (here constant) primary hash and a linear scan.869function hashCollisionKey(key) {870 if (typeof key !== 'string') {871 return hash(key);872 }873 var hashed = 0;874 for (var ii = 0; ii < key.length; ii++) {875 hashed = (COLLISION_HASH_BASE * hashed + key.charCodeAt(ii)) | 0;876 }877 return hashed;878}879function hashSymbol(sym) {880 var hashed = symbolMap[sym];881 if (hashed !== undefined) {882 return hashed;883 }884 hashed = nextHash();885 symbolMap[sym] = hashed;886 return hashed;887}888// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type889function hashJSObj(obj) {890 var hashed;891 if (usingWeakMap) {892 // @ts-expect-error weakMap is defined893 hashed = weakMap.get(obj);894 if (hashed !== undefined) {895 return hashed;896 }897 }898 // @ts-expect-error used for old code, will be removed899 hashed = obj[UID_HASH_KEY];900 if (hashed !== undefined) {901 return hashed;902 }903 if (!canDefineProperty) {904 // @ts-expect-error used for old code, will be removed905 hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];906 if (hashed !== undefined) {907 return hashed;908 }909 hashed = getIENodeHash(obj);910 if (hashed !== undefined) {911 return hashed;912 }913 }914 hashed = nextHash();915 if (usingWeakMap) {916 // @ts-expect-error weakMap is defined917 weakMap.set(obj, hashed);918 }919 else if (isExtensible !== undefined && isExtensible(obj) === false) {920 throw new Error('Non-extensible objects are not allowed as keys.');921 }922 else if (canDefineProperty) {923 Object.defineProperty(obj, UID_HASH_KEY, {924 enumerable: false,925 configurable: false,926 writable: false,927 value: hashed,928 });929 }930 else if (obj.propertyIsEnumerable !== undefined &&931 obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {932 // Since we can't define a non-enumerable property on the object933 // we'll hijack one of the less-used non-enumerable properties to934 // save our hash on it. Since this is a function it will not show up in935 // `JSON.stringify` which is what we want.936 obj.propertyIsEnumerable = function () {937 return this.constructor.prototype.propertyIsEnumerable.apply(this, 938 // eslint-disable-next-line prefer-rest-params939 arguments);940 };941 // @ts-expect-error used for old code, will be removed942 obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;943 // @ts-expect-error used for old code, will be removed944 }945 else if (obj.nodeType !== undefined) {946 // At this point we couldn't get the IE `uniqueID` to use as a hash947 // and we couldn't use a non-enumerable property to exploit the948 // dontEnum bug so we simply add the `UID_HASH_KEY` on the node949 // itself.950 // @ts-expect-error used for old code, will be removed951 obj[UID_HASH_KEY] = hashed;952 }953 else {954 throw new Error('Unable to set a non-enumerable property on object.');955 }956 return hashed;957}958// Get references to ES5 object methods.959var isExtensible = Object.isExtensible;960// True if Object.defineProperty works as expected. IE8 fails this test.961// TODO remove this as widely available https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty962var canDefineProperty = (function () {963 try {964 Object.defineProperty({}, '@', {});965 return true;966 // eslint-disable-next-line @typescript-eslint/no-unused-vars967 }968 catch (e) {969 return false;970 }971})();972// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it973// and avoid memory leaks from the IE cloneNode bug.974// TODO remove this method as only used if `canDefineProperty` is false975function getIENodeHash(node) {976 // @ts-expect-error don't care977 if (node && node.nodeType > 0) {978 // @ts-expect-error don't care979 switch (node.nodeType) {980 case 1: // Element981 // @ts-expect-error don't care982 return node.uniqueID;983 case 9: // Document984 // @ts-expect-error don't care985 return node.documentElement && node.documentElement.uniqueID;986 }987 }988}989function valueOf(obj) {990 return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function'991 ? // @ts-expect-error weird the "obj" parameter as `valueOf` should not have a parameter992 obj.valueOf(obj)993 : obj;994}995function nextHash() {996 var nextHash = ++_objHashUID;997 if (_objHashUID & 0x40000000) {998 _objHashUID = 0;999 }1000 return nextHash;1001}1002// If possible, use a WeakMap.1003// TODO using WeakMap should be true everywhere now that WeakMap is widely supported: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap1004var usingWeakMap = typeof WeakMap === 'function';1005var weakMap;1006if (usingWeakMap) {1007 weakMap = new WeakMap();1008}1009var symbolMap = Object.create(null);1010var _objHashUID = 0;1011// TODO remove string as Symbol is now widely supported: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol1012var UID_HASH_KEY = '__immutablehash__';1013if (typeof Symbol === 'function') {1014 UID_HASH_KEY = Symbol(UID_HASH_KEY);1015}1016var STRING_HASH_CACHE_MIN_STRLEN = 16;1017var STRING_HASH_CACHE_MAX_SIZE = 255;1018var STRING_HASH_CACHE_SIZE = 0;1019var stringHashCache = {};1020 1021var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) {1022 function ToKeyedSequence(indexed, useKeys) {1023 this._iter = indexed;1024 this._useKeys = useKeys;1025 this.size = indexed.size;1026 }1027 1028 if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq;1029 ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );1030 ToKeyedSequence.prototype.constructor = ToKeyedSequence;1031 1032 ToKeyedSequence.prototype.get = function get (key, notSetValue) {1033 return this._iter.get(key, notSetValue);1034 };1035 1036 ToKeyedSequence.prototype.has = function has (key) {1037 return this._iter.has(key);1038 };1039 1040 ToKeyedSequence.prototype.valueSeq = function valueSeq () {1041 return this._iter.valueSeq();1042 };1043 1044 ToKeyedSequence.prototype.reverse = function reverse () {1045 var this$1$1 = this;1046 1047 var reversedSequence = reverseFactory(this, true);1048 if (!this._useKeys) {1049 reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); };1050 }1051 return reversedSequence;1052 };1053 1054 ToKeyedSequence.prototype.map = function map (mapper, context) {1055 var this$1$1 = this;1056 1057 var mappedSequence = mapFactory(this, mapper, context);1058 if (!this._useKeys) {1059 mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); };1060 }1061 return mappedSequence;1062 };1063 1064 ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {1065 var this$1$1 = this;1066 1067 return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse);1068 };1069 1070 ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {1071 return this._iter.__iterator(type, reverse);1072 };1073 1074 return ToKeyedSequence;1075}(KeyedSeq));1076ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;1077 1078var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {1079 function ToIndexedSequence(iter) {1080 this._iter = iter;1081 this.size = iter.size;1082 }1083 1084 if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq;1085 ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );1086 ToIndexedSequence.prototype.constructor = ToIndexedSequence;1087 1088 ToIndexedSequence.prototype.includes = function includes (value) {1089 return this._iter.includes(value);1090 };1091 1092 ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {1093 var this$1$1 = this;1094 1095 var i = 0;1096 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here1097 reverse && ensureSize(this);1098 return this._iter.__iterate(1099 function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },1100 reverse1101 );1102 };1103 1104 ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {1105 var this$1$1 = this;1106 1107 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1108 var i = 0;1109 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here1110 reverse && ensureSize(this);1111 return new Iterator(function () {1112 var step = iterator.next();1113 return step.done1114 ? step1115 : iteratorValue(1116 type,1117 reverse ? this$1$1.size - ++i : i++,1118 step.value,1119 step1120 );1121 });1122 };1123 1124 return ToIndexedSequence;1125}(IndexedSeq));1126 1127var ToSetSequence = /*@__PURE__*/(function (SetSeq) {1128 function ToSetSequence(iter) {1129 this._iter = iter;1130 this.size = iter.size;1131 }1132 1133 if ( SetSeq ) ToSetSequence.__proto__ = SetSeq;1134 ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype );1135 ToSetSequence.prototype.constructor = ToSetSequence;1136 1137 ToSetSequence.prototype.has = function has (key) {1138 return this._iter.includes(key);1139 };1140 1141 ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {1142 var this$1$1 = this;1143 1144 return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse);1145 };1146 1147 ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {1148 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1149 return new Iterator(function () {1150 var step = iterator.next();1151 return step.done1152 ? step1153 : iteratorValue(type, step.value, step.value, step);1154 });1155 };1156 1157 return ToSetSequence;1158}(SetSeq));1159 1160var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) {1161 function FromEntriesSequence(entries) {1162 this._iter = entries;1163 this.size = entries.size;1164 }1165 1166 if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq;1167 FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );1168 FromEntriesSequence.prototype.constructor = FromEntriesSequence;1169 1170 FromEntriesSequence.prototype.entrySeq = function entrySeq () {1171 return this._iter.toSeq();1172 };1173 1174 FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {1175 var this$1$1 = this;1176 1177 return this._iter.__iterate(function (entry) {1178 // Check if entry exists first so array access doesn't throw for holes1179 // in the parent iteration.1180 if (entry) {1181 validateEntry(entry);1182 var indexedCollection = isCollection(entry);1183 return fn(1184 indexedCollection ? entry.get(1) : entry[1],1185 indexedCollection ? entry.get(0) : entry[0],1186 this$1$11187 );1188 }1189 }, reverse);1190 };1191 1192 FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {1193 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1194 return new Iterator(function () {1195 while (true) {1196 var step = iterator.next();1197 if (step.done) {1198 return step;1199 }1200 var entry = step.value;