26 lines
78 KiB
JavaScript
26 lines
78 KiB
JavaScript
|
|
/**
|
||
|
|
* @license
|
||
|
|
* MIT License
|
||
|
|
*
|
||
|
|
* Copyright (c) 2014-present, Lee Byron and other contributors.
|
||
|
|
*
|
||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
||
|
|
* in the Software without restriction, including without limitation the rights
|
||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
||
|
|
* furnished to do so, subject to the following conditions:
|
||
|
|
*
|
||
|
|
* The above copyright notice and this permission notice shall be included in all
|
||
|
|
* copies or substantial portions of the Software.
|
||
|
|
*
|
||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
|
* SOFTWARE.
|
||
|
|
*/
|
||
|
|
var IS_INDEXED_SYMBOL="@@__IMMUTABLE_INDEXED__@@";function isIndexed(t){return Boolean(t&&t[IS_INDEXED_SYMBOL])}var IS_KEYED_SYMBOL="@@__IMMUTABLE_KEYED__@@";function isKeyed(t){return Boolean(t&&t[IS_KEYED_SYMBOL])}function isAssociative(t){return isKeyed(t)||isIndexed(t)}var IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isCollection(t){return Boolean(t&&t[IS_COLLECTION_SYMBOL])}var Collection=function(t){return isCollection(t)?t:Seq(t)},KeyedCollection=function(t){function e(t){return isKeyed(t)?t:KeyedSeq(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Collection),IndexedCollection=function(t){function e(t){return isIndexed(t)?t:IndexedSeq(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Collection),SetCollection=function(t){function e(t){return isCollection(t)&&!isAssociative(t)?t:SetSeq(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Collection);Collection.Keyed=KeyedCollection,Collection.Indexed=IndexedCollection,Collection.Set=SetCollection;var ITERATE_KEYS=0,ITERATE_VALUES=1,ITERATE_ENTRIES=2,REAL_ITERATOR_SYMBOL="function"==typeof Symbol&&Symbol.iterator,FAUX_ITERATOR_SYMBOL="@@iterator",ITERATOR_SYMBOL=REAL_ITERATOR_SYMBOL||FAUX_ITERATOR_SYMBOL,Iterator=function(t){this.next=t};function iteratorValue(t,e,r,n){var o=t===ITERATE_KEYS?e:t===ITERATE_VALUES?r:[e,r];return n?n.value=o:n={value:o,done:!1},n}function iteratorDone(){return{value:void 0,done:!0}}function hasIterator(t){return!!Array.isArray(t)||!!getIteratorFn(t)}function isIterator(t){return!(!t||"function"!=typeof t.next)}function getIterator(t){var e=getIteratorFn(t);return e&&e.call(t)}function getIteratorFn(t){var e=t&&(REAL_ITERATOR_SYMBOL&&t[REAL_ITERATOR_SYMBOL]||t[FAUX_ITERATOR_SYMBOL]);if("function"==typeof e)return e}function isEntriesIterable(t){var e=getIteratorFn(t);return e&&e===t.entries}function isKeysIterable(t){var e=getIteratorFn(t);return e&&e===t.keys}Iterator.prototype.toString=function(){return"[Iterator]"},Iterator.KEYS=ITERATE_KEYS,Iterator.VALUES=ITERATE_VALUES,Iterator.ENTRIES=ITERATE_ENTRIES,Iterator.prototype.inspect=Iterator.prototype.toSource=function(){return this.toString()},Iterator.prototype[ITERATOR_SYMBOL]=function(){return this};var DELETE="delete",SHIFT=5,SIZE=1<<SHIFT,MASK=SIZE-1,NOT_SET={};function MakeRef(){return{value:!1}}function SetRef(t){t&&(t.value=!0)}function OwnerID(){}function ensureSize(t){return void 0===t.size&&(t.size=t.__iterate(returnTrue)),t.size}function wrapIndex(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?ensureSize(t)+e:e}function returnTrue(){return!0}function wholeSlice(t,e,r){return(0===t&&!isNeg(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function resolveBegin(t,e){return resolveIndex(t,e,0)}function resolveEnd(t,e){return resolveIndex(t,e,e)}function resolveIndex(t,e,r){return void 0===t?r:isNeg(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function isNeg(t){return t<0||0===t&&1/t==-1/0}var IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@";function isRecord(t){return Boolean(t&&t[IS_RECORD_SYMBOL])}function isImmutable(t){return isCollection(t)||isRecord(t)}var IS_ORDERED_SYMBOL="@@__IMMUTABLE_ORDERED__@@";function isOrdered(t){return Boolean(t&&t[IS_ORDERED_SYMBOL])}var IS_SEQ_SYMBOL="@@__IMMUTABLE_SEQ__@@";function isSeq(t){return Boolean(t&&t[IS_SEQ_SYMBOL])}var hasOwnProperty=Object.prototype.hasOwnProperty;function isArrayLike(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var Seq=function(t){function e(t){return null==t?emptySequence():isImmutable(t)?t.toSeq():seqFromValue(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=func
|