/** * Copyright (c) 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory.
*/
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on. varDELETE = 'delete';
// Constants describing the size of trie nodes. var SHIFT = 5; // Resulted in best performance after ______? var SIZE = 1 << SHIFT; var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other // than itself, and nothing that could be provided externally. var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`. var CHANGE_LENGTH = { value: false }; var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false; return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes // to tries. The return value will only ever equal itself, and will not equal // the return of any subsequent call of this function. function OwnerID() {}
// http://jsperf.com/copy-array-inline function arrCopy(arr, offset) {
offset = offset || 0; var len = Math.max(0, arr.length - offset); var newArr = new Array(len); for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
} return newArr;
}
function ensureSize(iter) { if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
} return iter.size;
}
function wrapIndex(iter, index) { // This implements "is array index" which the ECMAString spec defines as: // // A String property name P is an array index if and only if // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal // to 2^32−1. // // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects if (typeof index !== 'number') { var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 if ('' + uint32Index !== index || uint32Index === 4294967295) { return NaN;
}
index = uint32Index;
} return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() { returntrue;
}
function wholeSlice(begin, end, size) { return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) { return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) { return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) { return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0; var ITERATE_VALUES = 1; var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) { if (reverse) { returnthis.cacheResult().__iterate(fn, reverse);
} var iterator = this._iterator; var cache = this._iteratorCache; var iterations = 0; while (iterations < cache.length) { if (fn(cache[iterations], iterations++, this) === false) { return iterations;
}
} var step; while (!(step = iterator.next()).done) { var val = step.value;
cache[iterations] = val; if (fn(val, iterations++, this) === false) { break;
}
} return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) { if (reverse) { returnthis.cacheResult().__iterator(type, reverse);
} var iterator = this._iterator; var cache = this._iteratorCache; var iterations = 0; returnnew Iterator(function() { if (iterations >= cache.length) { var step = iterator.next(); if (step.done) { return step;
}
cache[iterations] = step.value;
} return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) { return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() { return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) { var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() : typeof value === 'object' ? new ObjectSeq(value) :
undefined; if (!seq) { thrownew TypeError( 'Expected Array or iterable object of [k, v] entries, '+ 'or keyed object: ' + value
);
} return seq;
}
function indexedSeqFromValue(value) { var seq = maybeIndexedSeqFromValue(value); if (!seq) { thrownew TypeError( 'Expected Array or iterable object of values: ' + value
);
} return seq;
}
function seqFromValue(value) { var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value)); if (!seq) { thrownew TypeError( 'Expected Array or iterable object of values, or keyed object: ' + value
);
} return seq;
}
function maybeIndexedSeqFromValue(value) { return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) { var cache = seq._cache; if (cache) { var maxIndex = cache.length - 1; for (var ii = 0; ii <= maxIndex; ii++) { var entry = cache[reverse ? maxIndex - ii : ii]; if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) { return ii + 1;
}
} return ii;
} return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) { var cache = seq._cache; if (cache) { var maxIndex = cache.length - 1; var ii = 0; returnnew Iterator(function() { var entry = cache[reverse ? maxIndex - ii : ii]; return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
} return seq.__iteratorUncached(type, reverse);
}
function fromJSDefault(json) { if (Array.isArray(json)) { return IndexedSeq(json).map(fromJSDefault).toList();
} if (isPlainObj(json)) { return KeyedSeq(json).map(fromJSDefault).toMap();
} return json;
}
function isPlainObj(value) { return value && (value.constructor === Object || value.constructor === undefined);
}
/** * An extension of the "same-value" algorithm as [described for use by ES6 Map * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) * * NaN is considered the same as NaN, however -0 and 0 are considered the same * value, which is different from the algorithm described by * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). * * This is extended further to allow Objects to describe the values they * represent, by way of `valueOf` or `equals` (and `hashCode`). * * Note: because of this extension, the key equality of Immutable.Map and the * value equality of Immutable.Set will differ from ES6 Map and Set. * * ### Defining custom values * * The easiest way to describe the value an object represents is by implementing * `valueOf`. For example, `Date` represents a value by returning a unix * timestamp for `valueOf`: * * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... * var date2 = new Date(1234567890000); * date1.valueOf(); // 1234567890000 * assert( date1 !== date2 ); * assert( Immutable.is( date1, date2 ) ); * * Note: overriding `valueOf` may have other implications if you use this object * where JavaScript expects a primitive, such as implicit string coercion. * * For more complex types, especially collections, implementing `valueOf` may * not be performant. An alternative is to implement `equals` and `hashCode`. * * `equals` takes another object, presumably of similar type, and returns true * if the it is equal. Equality is symmetrical, so the same result should be * returned if this and the argument are flipped. * * assert( a.equals(b) === b.equals(a) ); * * `hashCode` returns a 32bit integer number representing the object which will * be used to determine how to store the value object in a Map or Set. You must * provide both or neither methods, one must not exist without the other. * * Also, an important relationship between these methods must be upheld: if two * values are equal, they *must* return the same hashCode. If the values are not * equal, they might have the same hashCode; this is called a hash collision, * and while undesirable for performance reasons, it is acceptable. * * if (a.equals(b)) { * assert( a.hashCode() === b.hashCode() ); * } * * All Immutable collections implement `equals` and `hashCode`. *
*/ function is(valueA, valueB) { if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { returntrue;
} if (!valueA || !valueB) { returnfalse;
} if (typeof valueA.valueOf === 'function' && typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf(); if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { returntrue;
} if (!valueA || !valueB) { returnfalse;
}
} if (typeof valueA.equals === 'function' && typeof valueB.equals === 'function' &&
valueA.equals(valueB)) { returntrue;
} returnfalse;
}
function deepEqual(a, b) { if (a === b) { returntrue;
}
var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul : function imul(a, b) {
a = a | 0; // int
b = b | 0; // int var c = a & 0xffff; var d = b & 0xffff; // Shift by 0 fixes the sign on the high part. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers. // Values which have either 00 or 11 as the high order bits qualify. // This function drops the highest order bit in a signed number, maintaining // the sign bit. function smi(i32) { return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) { if (o === false || o === null || o === undefined) { return 0;
} if (typeof o.valueOf === 'function') {
o = o.valueOf(); if (o === false || o === null || o === undefined) { return 0;
}
} if (o === true) { return 1;
} var type = typeof o; if (type === 'number') { var h = o | 0; if (h !== o) {
h ^= o * 0xFFFFFFFF;
} while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
} return smi(h);
} if (type === 'string') { return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
} if (typeof o.hashCode === 'function') { return o.hashCode();
} if (type === 'object') { return hashJSObj(o);
} if (typeof o.toString === 'function') { return hashString(o.toString());
} thrownew Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) { var hash = stringHashCache[string]; if (hash === undefined) {
hash = hashString(string); if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
} return hash;
}
// http://jsperf.com/hashing-strings function hashString(string) { // This is the hash from JVM // The hash code for a string is computed as // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], // where s[i] is the ith character of the string and n is the length of // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 // (exclusive) by dropping high bits. var hash = 0; for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
} return smi(hash);
}
function hashJSObj(obj) { var hash; if (usingWeakMap) {
hash = weakMap.get(obj); if (hash !== undefined) { return hash;
}
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} elseif (isExtensible !== undefined && isExtensible(obj) === false) { thrownew Error('Non-extensible objects are not allowed as keys.');
} elseif (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, { 'enumerable': false, 'configurable': false, 'writable': false, 'value': hash
});
} elseif (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { // Since we can't define a non-enumerable property on the object // we'll hijack one of the less-used non-enumerable properties to // save our hash on it. Since this is a function it will not show up in // `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() { returnthis.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} elseif (obj.nodeType !== undefined) { // At this point we couldn't get the IE `uniqueID` to use as a hash // and we couldn't use a non-enumerable property to exploit the // dontEnum bug so we simply add the `UID_HASH_KEY` on the node // itself.
obj[UID_HASH_KEY] = hash;
} else { thrownew Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods. var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test. var canDefineProperty = (function() { try {
Object.defineProperty({}, '@', {}); returntrue;
} catch (e) { returnfalse;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it // and avoid memory leaks from the IE cloneNode bug. function getIENodeHash(node) { if (node && node.nodeType > 0) { switch (node.nodeType) { case 1: // Element return node.uniqueID; case 9: // Document return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap. var usingWeakMap = typeof WeakMap === 'function'; var weakMap; if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__'; if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16; var STRING_HASH_CACHE_MAX_SIZE = 255; var STRING_HASH_CACHE_SIZE = 0; var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity, 'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) { return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) { var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.of = function() {var keyValues = SLICE$0.call(arguments, 0); return emptyMap().withMutations(function(map ) { for (var i = 0; i < keyValues.length; i += 2) { if (i + 1 >= keyValues.length) { thrownew Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
};
function createNodes(ownerID, entries, key, value) { if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]); for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
} return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count); for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii]; if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
} return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE); for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node; return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = []; for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value); if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
} return mergeIntoCollectionWith(map, merger, iters);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16); return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val; return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1; if (canEdit && idx + 1 === newLen) {
array[idx] = val; return array;
}
var newArray = new Array(newLen);
var after = 0; for (var ii = 0; ii < newLen; ii++) { if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
} return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1; if (canEdit && idx === newLen) {
array.pop(); return array;
}
var newArray = new Array(newLen);
var after = 0; for (var ii = 0; ii < newLen; ii++) { if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
} return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList(); if (value === null || value === undefined) { return empty;
} if (isList(value)) { return value;
}
var iter = IndexedIterable(value);
var size = iter.size; if (size === 0) { return empty;
}
assertNotInfinite(size); if (size > 0 && size < SIZE) { return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
} return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse); return new Iterator(function() {
var value = values(); return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value; while ((value = values()) !== DONE) { if (fn(value, index++, this) === false) { break;
}
} return index;
};
var newChild; if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); if (newChild === oldChild && sizeIndex === this.array.length - 1) { return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1); if (newChild) {
editable.array[sizeIndex] = newChild;
} return editable;
};
var DONE = {};
function iterateList(list, reverse) {
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.80Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.