immutable 4.0.0-rc.5 → 4.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -83
- package/dist/immutable-nonambient.d.ts +951 -479
- package/dist/immutable.d.ts +951 -479
- package/dist/immutable.es.js +542 -339
- package/dist/immutable.js +555 -338
- package/dist/immutable.js.flow +331 -111
- package/dist/immutable.min.js +32 -31
- package/package.json +2 -2
package/dist/immutable.js
CHANGED
|
@@ -41,17 +41,6 @@ function SetRef(ref) {
|
|
|
41
41
|
// the return of any subsequent call of this function.
|
|
42
42
|
function OwnerID() {}
|
|
43
43
|
|
|
44
|
-
// http://jsperf.com/copy-array-inline
|
|
45
|
-
function arrCopy(arr, offset) {
|
|
46
|
-
offset = offset || 0;
|
|
47
|
-
var len = Math.max(0, arr.length - offset);
|
|
48
|
-
var newArr = new Array(len);
|
|
49
|
-
for (var ii = 0; ii < len; ii++) {
|
|
50
|
-
newArr[ii] = arr[ii + offset];
|
|
51
|
-
}
|
|
52
|
-
return newArr;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
44
|
function ensureSize(iter) {
|
|
56
45
|
if (iter.size === undefined) {
|
|
57
46
|
iter.size = iter.__iterate(returnTrue);
|
|
@@ -115,10 +104,7 @@ function isNeg(value) {
|
|
|
115
104
|
}
|
|
116
105
|
|
|
117
106
|
function isImmutable(maybeImmutable) {
|
|
118
|
-
return (
|
|
119
|
-
(isCollection(maybeImmutable) || isRecord(maybeImmutable)) &&
|
|
120
|
-
!maybeImmutable.__ownerID
|
|
121
|
-
);
|
|
107
|
+
return isCollection(maybeImmutable) || isRecord(maybeImmutable);
|
|
122
108
|
}
|
|
123
109
|
|
|
124
110
|
function isCollection(maybeCollection) {
|
|
@@ -269,6 +255,8 @@ function getIteratorFn(iterable) {
|
|
|
269
255
|
}
|
|
270
256
|
}
|
|
271
257
|
|
|
258
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
259
|
+
|
|
272
260
|
function isArrayLike(value) {
|
|
273
261
|
return value && typeof value.length === 'number';
|
|
274
262
|
}
|
|
@@ -277,9 +265,7 @@ var Seq = (function (Collection$$1) {
|
|
|
277
265
|
function Seq(value) {
|
|
278
266
|
return value === null || value === undefined
|
|
279
267
|
? emptySequence()
|
|
280
|
-
:
|
|
281
|
-
? value.toSeq()
|
|
282
|
-
: seqFromValue(value);
|
|
268
|
+
: isImmutable(value) ? value.toSeq() : seqFromValue(value);
|
|
283
269
|
}
|
|
284
270
|
|
|
285
271
|
if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
|
|
@@ -492,7 +478,7 @@ var ObjectSeq = (function (KeyedSeq) {
|
|
|
492
478
|
};
|
|
493
479
|
|
|
494
480
|
ObjectSeq.prototype.has = function has (key) {
|
|
495
|
-
return this._object
|
|
481
|
+
return hasOwnProperty.call(this._object, key);
|
|
496
482
|
};
|
|
497
483
|
|
|
498
484
|
ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
|
|
@@ -1878,6 +1864,28 @@ function defaultComparator(a, b) {
|
|
|
1878
1864
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
1879
1865
|
}
|
|
1880
1866
|
|
|
1867
|
+
// http://jsperf.com/copy-array-inline
|
|
1868
|
+
function arrCopy(arr, offset) {
|
|
1869
|
+
offset = offset || 0;
|
|
1870
|
+
var len = Math.max(0, arr.length - offset);
|
|
1871
|
+
var newArr = new Array(len);
|
|
1872
|
+
for (var ii = 0; ii < len; ii++) {
|
|
1873
|
+
newArr[ii] = arr[ii + offset];
|
|
1874
|
+
}
|
|
1875
|
+
return newArr;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
function invariant(condition, error) {
|
|
1879
|
+
if (!condition) { throw new Error(error); }
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
function assertNotInfinite(size) {
|
|
1883
|
+
invariant(
|
|
1884
|
+
size !== Infinity,
|
|
1885
|
+
'Cannot perform this action with an infinite size.'
|
|
1886
|
+
);
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1881
1889
|
function coerceKeyPath(keyPath) {
|
|
1882
1890
|
if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
|
|
1883
1891
|
return keyPath;
|
|
@@ -1890,15 +1898,18 @@ function coerceKeyPath(keyPath) {
|
|
|
1890
1898
|
);
|
|
1891
1899
|
}
|
|
1892
1900
|
|
|
1893
|
-
function
|
|
1894
|
-
|
|
1901
|
+
function isPlainObj(value) {
|
|
1902
|
+
return (
|
|
1903
|
+
value && (value.constructor === Object || value.constructor === undefined)
|
|
1904
|
+
);
|
|
1895
1905
|
}
|
|
1896
1906
|
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1907
|
+
/**
|
|
1908
|
+
* Returns true if the value is a potentially-persistent data structure, either
|
|
1909
|
+
* provided by Immutable.js or a plain Array or Object.
|
|
1910
|
+
*/
|
|
1911
|
+
function isDataStructure(value) {
|
|
1912
|
+
return isImmutable(value) || Array.isArray(value) || isPlainObj(value);
|
|
1902
1913
|
}
|
|
1903
1914
|
|
|
1904
1915
|
/**
|
|
@@ -1912,6 +1923,347 @@ function quoteString(value) {
|
|
|
1912
1923
|
}
|
|
1913
1924
|
}
|
|
1914
1925
|
|
|
1926
|
+
function has(collection, key) {
|
|
1927
|
+
return isImmutable(collection)
|
|
1928
|
+
? collection.has(key)
|
|
1929
|
+
: isDataStructure(collection) && hasOwnProperty.call(collection, key);
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function get(collection, key, notSetValue) {
|
|
1933
|
+
return isImmutable(collection)
|
|
1934
|
+
? collection.get(key, notSetValue)
|
|
1935
|
+
: !has(collection, key)
|
|
1936
|
+
? notSetValue
|
|
1937
|
+
: typeof collection.get === 'function'
|
|
1938
|
+
? collection.get(key)
|
|
1939
|
+
: collection[key];
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
function shallowCopy(from) {
|
|
1943
|
+
if (Array.isArray(from)) {
|
|
1944
|
+
return arrCopy(from);
|
|
1945
|
+
}
|
|
1946
|
+
var to = {};
|
|
1947
|
+
for (var key in from) {
|
|
1948
|
+
if (hasOwnProperty.call(from, key)) {
|
|
1949
|
+
to[key] = from[key];
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
return to;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
function remove(collection, key) {
|
|
1956
|
+
if (!isDataStructure(collection)) {
|
|
1957
|
+
throw new TypeError(
|
|
1958
|
+
'Cannot update non-data-structure value: ' + collection
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
if (isImmutable(collection)) {
|
|
1962
|
+
if (!collection.remove) {
|
|
1963
|
+
throw new TypeError(
|
|
1964
|
+
'Cannot update immutable value without .remove() method: ' + collection
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
return collection.remove(key);
|
|
1968
|
+
}
|
|
1969
|
+
if (!hasOwnProperty.call(collection, key)) {
|
|
1970
|
+
return collection;
|
|
1971
|
+
}
|
|
1972
|
+
var collectionCopy = shallowCopy(collection);
|
|
1973
|
+
if (Array.isArray(collectionCopy)) {
|
|
1974
|
+
collectionCopy.splice(key, 1);
|
|
1975
|
+
} else {
|
|
1976
|
+
delete collectionCopy[key];
|
|
1977
|
+
}
|
|
1978
|
+
return collectionCopy;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function set(collection, key, value) {
|
|
1982
|
+
if (!isDataStructure(collection)) {
|
|
1983
|
+
throw new TypeError(
|
|
1984
|
+
'Cannot update non-data-structure value: ' + collection
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1987
|
+
if (isImmutable(collection)) {
|
|
1988
|
+
if (!collection.set) {
|
|
1989
|
+
throw new TypeError(
|
|
1990
|
+
'Cannot update immutable value without .set() method: ' + collection
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
return collection.set(key, value);
|
|
1994
|
+
}
|
|
1995
|
+
if (hasOwnProperty.call(collection, key) && value === collection[key]) {
|
|
1996
|
+
return collection;
|
|
1997
|
+
}
|
|
1998
|
+
var collectionCopy = shallowCopy(collection);
|
|
1999
|
+
collectionCopy[key] = value;
|
|
2000
|
+
return collectionCopy;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
function updateIn(collection, keyPath, notSetValue, updater) {
|
|
2004
|
+
if (!updater) {
|
|
2005
|
+
updater = notSetValue;
|
|
2006
|
+
notSetValue = undefined;
|
|
2007
|
+
}
|
|
2008
|
+
var updatedValue = updateInDeeply(
|
|
2009
|
+
isImmutable(collection),
|
|
2010
|
+
collection,
|
|
2011
|
+
coerceKeyPath(keyPath),
|
|
2012
|
+
0,
|
|
2013
|
+
notSetValue,
|
|
2014
|
+
updater
|
|
2015
|
+
);
|
|
2016
|
+
return updatedValue === NOT_SET ? notSetValue : updatedValue;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
function updateInDeeply(
|
|
2020
|
+
inImmutable,
|
|
2021
|
+
existing,
|
|
2022
|
+
keyPath,
|
|
2023
|
+
i,
|
|
2024
|
+
notSetValue,
|
|
2025
|
+
updater
|
|
2026
|
+
) {
|
|
2027
|
+
var wasNotSet = existing === NOT_SET;
|
|
2028
|
+
if (i === keyPath.length) {
|
|
2029
|
+
var existingValue = wasNotSet ? notSetValue : existing;
|
|
2030
|
+
var newValue = updater(existingValue);
|
|
2031
|
+
return newValue === existingValue ? existing : newValue;
|
|
2032
|
+
}
|
|
2033
|
+
if (!wasNotSet && !isDataStructure(existing)) {
|
|
2034
|
+
throw new TypeError(
|
|
2035
|
+
'Cannot update within non-data-structure value in path [' +
|
|
2036
|
+
keyPath.slice(0, i).map(quoteString) +
|
|
2037
|
+
']: ' +
|
|
2038
|
+
existing
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
var key = keyPath[i];
|
|
2042
|
+
var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
|
|
2043
|
+
var nextUpdated = updateInDeeply(
|
|
2044
|
+
nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
|
|
2045
|
+
nextExisting,
|
|
2046
|
+
keyPath,
|
|
2047
|
+
i + 1,
|
|
2048
|
+
notSetValue,
|
|
2049
|
+
updater
|
|
2050
|
+
);
|
|
2051
|
+
return nextUpdated === nextExisting
|
|
2052
|
+
? existing
|
|
2053
|
+
: nextUpdated === NOT_SET
|
|
2054
|
+
? remove(existing, key)
|
|
2055
|
+
: set(
|
|
2056
|
+
wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
|
|
2057
|
+
key,
|
|
2058
|
+
nextUpdated
|
|
2059
|
+
);
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
function setIn$1(collection, keyPath, value) {
|
|
2063
|
+
return updateIn(collection, keyPath, NOT_SET, function () { return value; });
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function setIn$$1(keyPath, v) {
|
|
2067
|
+
return setIn$1(this, keyPath, v);
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
function removeIn(collection, keyPath) {
|
|
2071
|
+
return updateIn(collection, keyPath, function () { return NOT_SET; });
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
function deleteIn(keyPath) {
|
|
2075
|
+
return removeIn(this, keyPath);
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
function update$1(collection, key, notSetValue, updater) {
|
|
2079
|
+
return updateIn(collection, [key], notSetValue, updater);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
function update$$1(key, notSetValue, updater) {
|
|
2083
|
+
return arguments.length === 1
|
|
2084
|
+
? key(this)
|
|
2085
|
+
: update$1(this, key, notSetValue, updater);
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
function updateIn$1(keyPath, notSetValue, updater) {
|
|
2089
|
+
return updateIn(this, keyPath, notSetValue, updater);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
function merge() {
|
|
2093
|
+
var iters = [], len = arguments.length;
|
|
2094
|
+
while ( len-- ) iters[ len ] = arguments[ len ];
|
|
2095
|
+
|
|
2096
|
+
return mergeIntoKeyedWith(this, iters);
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
function mergeWith(merger) {
|
|
2100
|
+
var iters = [], len = arguments.length - 1;
|
|
2101
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2102
|
+
|
|
2103
|
+
return mergeIntoKeyedWith(this, iters, merger);
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
function mergeIntoKeyedWith(collection, collections, merger) {
|
|
2107
|
+
var iters = [];
|
|
2108
|
+
for (var ii = 0; ii < collections.length; ii++) {
|
|
2109
|
+
var collection$1 = KeyedCollection(collections[ii]);
|
|
2110
|
+
if (collection$1.size !== 0) {
|
|
2111
|
+
iters.push(collection$1);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
if (iters.length === 0) {
|
|
2115
|
+
return collection;
|
|
2116
|
+
}
|
|
2117
|
+
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
|
|
2118
|
+
return collection.constructor(iters[0]);
|
|
2119
|
+
}
|
|
2120
|
+
return collection.withMutations(function (collection) {
|
|
2121
|
+
var mergeIntoCollection = merger
|
|
2122
|
+
? function (value, key) {
|
|
2123
|
+
update$1(
|
|
2124
|
+
collection,
|
|
2125
|
+
key,
|
|
2126
|
+
NOT_SET,
|
|
2127
|
+
function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
|
|
2128
|
+
);
|
|
2129
|
+
}
|
|
2130
|
+
: function (value, key) {
|
|
2131
|
+
collection.set(key, value);
|
|
2132
|
+
};
|
|
2133
|
+
for (var ii = 0; ii < iters.length; ii++) {
|
|
2134
|
+
iters[ii].forEach(mergeIntoCollection);
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
function merge$1(collection) {
|
|
2140
|
+
var sources = [], len = arguments.length - 1;
|
|
2141
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
2142
|
+
|
|
2143
|
+
return mergeWithSources(collection, sources);
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
function mergeWith$1(merger, collection) {
|
|
2147
|
+
var sources = [], len = arguments.length - 2;
|
|
2148
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
2149
|
+
|
|
2150
|
+
return mergeWithSources(collection, sources, merger);
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
function mergeDeep$1(collection) {
|
|
2154
|
+
var sources = [], len = arguments.length - 1;
|
|
2155
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
2156
|
+
|
|
2157
|
+
return mergeDeepWithSources(collection, sources);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
function mergeDeepWith$1(merger, collection) {
|
|
2161
|
+
var sources = [], len = arguments.length - 2;
|
|
2162
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
2163
|
+
|
|
2164
|
+
return mergeDeepWithSources(collection, sources, merger);
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
function mergeDeepWithSources(collection, sources, merger) {
|
|
2168
|
+
return mergeWithSources(collection, sources, deepMergerWith(merger));
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
function mergeWithSources(collection, sources, merger) {
|
|
2172
|
+
if (!isDataStructure(collection)) {
|
|
2173
|
+
throw new TypeError(
|
|
2174
|
+
'Cannot merge into non-data-structure value: ' + collection
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
if (isImmutable(collection)) {
|
|
2178
|
+
return collection.mergeWith
|
|
2179
|
+
? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
|
|
2180
|
+
: collection.concat.apply(collection, sources);
|
|
2181
|
+
}
|
|
2182
|
+
var isArray = Array.isArray(collection);
|
|
2183
|
+
var merged = collection;
|
|
2184
|
+
var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
|
|
2185
|
+
var mergeItem = isArray
|
|
2186
|
+
? function (value) {
|
|
2187
|
+
// Copy on write
|
|
2188
|
+
if (merged === collection) {
|
|
2189
|
+
merged = shallowCopy(merged);
|
|
2190
|
+
}
|
|
2191
|
+
merged.push(value);
|
|
2192
|
+
}
|
|
2193
|
+
: function (value, key) {
|
|
2194
|
+
var hasVal = hasOwnProperty.call(merged, key);
|
|
2195
|
+
var nextVal =
|
|
2196
|
+
hasVal && merger ? merger(merged[key], value, key) : value;
|
|
2197
|
+
if (!hasVal || nextVal !== merged[key]) {
|
|
2198
|
+
// Copy on write
|
|
2199
|
+
if (merged === collection) {
|
|
2200
|
+
merged = shallowCopy(merged);
|
|
2201
|
+
}
|
|
2202
|
+
merged[key] = nextVal;
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
for (var i = 0; i < sources.length; i++) {
|
|
2206
|
+
Collection$$1(sources[i]).forEach(mergeItem);
|
|
2207
|
+
}
|
|
2208
|
+
return merged;
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
function deepMergerWith(merger) {
|
|
2212
|
+
function deepMerger(oldValue, newValue, key) {
|
|
2213
|
+
return isDataStructure(oldValue) && isDataStructure(newValue)
|
|
2214
|
+
? mergeWithSources(oldValue, [newValue], deepMerger)
|
|
2215
|
+
: merger ? merger(oldValue, newValue, key) : newValue;
|
|
2216
|
+
}
|
|
2217
|
+
return deepMerger;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
function mergeDeep() {
|
|
2221
|
+
var iters = [], len = arguments.length;
|
|
2222
|
+
while ( len-- ) iters[ len ] = arguments[ len ];
|
|
2223
|
+
|
|
2224
|
+
return mergeDeepWithSources(this, iters);
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
function mergeDeepWith(merger) {
|
|
2228
|
+
var iters = [], len = arguments.length - 1;
|
|
2229
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2230
|
+
|
|
2231
|
+
return mergeDeepWithSources(this, iters, merger);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
function mergeIn(keyPath) {
|
|
2235
|
+
var iters = [], len = arguments.length - 1;
|
|
2236
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2237
|
+
|
|
2238
|
+
return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
function mergeDeepIn(keyPath) {
|
|
2242
|
+
var iters = [], len = arguments.length - 1;
|
|
2243
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2244
|
+
|
|
2245
|
+
return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
|
|
2246
|
+
);
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
function withMutations(fn) {
|
|
2250
|
+
var mutable = this.asMutable();
|
|
2251
|
+
fn(mutable);
|
|
2252
|
+
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function asMutable() {
|
|
2256
|
+
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
function asImmutable() {
|
|
2260
|
+
return this.__ensureOwner();
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
function wasAltered() {
|
|
2264
|
+
return this.__altered;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
1915
2267
|
var Map = (function (KeyedCollection$$1) {
|
|
1916
2268
|
function Map(value) {
|
|
1917
2269
|
return value === null || value === undefined
|
|
@@ -1961,22 +2313,10 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
1961
2313
|
return updateMap(this, k, v);
|
|
1962
2314
|
};
|
|
1963
2315
|
|
|
1964
|
-
Map.prototype.setIn = function setIn (keyPath, v) {
|
|
1965
|
-
return this.updateIn(keyPath, NOT_SET, function () { return v; });
|
|
1966
|
-
};
|
|
1967
|
-
|
|
1968
2316
|
Map.prototype.remove = function remove (k) {
|
|
1969
2317
|
return updateMap(this, k, NOT_SET);
|
|
1970
2318
|
};
|
|
1971
2319
|
|
|
1972
|
-
Map.prototype.deleteIn = function deleteIn (keyPath) {
|
|
1973
|
-
keyPath = [].concat( coerceKeyPath(keyPath) );
|
|
1974
|
-
if (keyPath.length) {
|
|
1975
|
-
var lastKey = keyPath.pop();
|
|
1976
|
-
return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); });
|
|
1977
|
-
}
|
|
1978
|
-
};
|
|
1979
|
-
|
|
1980
2320
|
Map.prototype.deleteAll = function deleteAll (keys) {
|
|
1981
2321
|
var collection = Collection(keys);
|
|
1982
2322
|
|
|
@@ -1989,27 +2329,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
1989
2329
|
});
|
|
1990
2330
|
};
|
|
1991
2331
|
|
|
1992
|
-
Map.prototype.update = function update (k, notSetValue, updater) {
|
|
1993
|
-
return arguments.length === 1
|
|
1994
|
-
? k(this)
|
|
1995
|
-
: this.updateIn([k], notSetValue, updater);
|
|
1996
|
-
};
|
|
1997
|
-
|
|
1998
|
-
Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) {
|
|
1999
|
-
if (!updater) {
|
|
2000
|
-
updater = notSetValue;
|
|
2001
|
-
notSetValue = undefined;
|
|
2002
|
-
}
|
|
2003
|
-
var updatedValue = updateInDeepMap(
|
|
2004
|
-
this,
|
|
2005
|
-
coerceKeyPath(keyPath),
|
|
2006
|
-
0,
|
|
2007
|
-
notSetValue,
|
|
2008
|
-
updater
|
|
2009
|
-
);
|
|
2010
|
-
return updatedValue === NOT_SET ? notSetValue : updatedValue;
|
|
2011
|
-
};
|
|
2012
|
-
|
|
2013
2332
|
Map.prototype.clear = function clear () {
|
|
2014
2333
|
if (this.size === 0) {
|
|
2015
2334
|
return this;
|
|
@@ -2026,54 +2345,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
2026
2345
|
|
|
2027
2346
|
// @pragma Composition
|
|
2028
2347
|
|
|
2029
|
-
Map.prototype.merge = function merge (/*...iters*/) {
|
|
2030
|
-
return mergeIntoMapWith(this, undefined, arguments);
|
|
2031
|
-
};
|
|
2032
|
-
|
|
2033
|
-
Map.prototype.mergeWith = function mergeWith (merger) {
|
|
2034
|
-
var iters = [], len = arguments.length - 1;
|
|
2035
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2036
|
-
|
|
2037
|
-
return mergeIntoMapWith(this, merger, iters);
|
|
2038
|
-
};
|
|
2039
|
-
|
|
2040
|
-
Map.prototype.mergeIn = function mergeIn (keyPath) {
|
|
2041
|
-
var iters = [], len = arguments.length - 1;
|
|
2042
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2043
|
-
|
|
2044
|
-
return this.updateIn(
|
|
2045
|
-
keyPath,
|
|
2046
|
-
emptyMap(),
|
|
2047
|
-
function (m) { return typeof m.merge === 'function'
|
|
2048
|
-
? m.merge.apply(m, iters)
|
|
2049
|
-
: iters[iters.length - 1]; }
|
|
2050
|
-
);
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) {
|
|
2054
|
-
return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments);
|
|
2055
|
-
};
|
|
2056
|
-
|
|
2057
|
-
Map.prototype.mergeDeepWith = function mergeDeepWith (merger) {
|
|
2058
|
-
var iters = [], len = arguments.length - 1;
|
|
2059
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2060
|
-
|
|
2061
|
-
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
|
|
2062
|
-
};
|
|
2063
|
-
|
|
2064
|
-
Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) {
|
|
2065
|
-
var iters = [], len = arguments.length - 1;
|
|
2066
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2067
|
-
|
|
2068
|
-
return this.updateIn(
|
|
2069
|
-
keyPath,
|
|
2070
|
-
emptyMap(),
|
|
2071
|
-
function (m) { return typeof m.mergeDeep === 'function'
|
|
2072
|
-
? m.mergeDeep.apply(m, iters)
|
|
2073
|
-
: iters[iters.length - 1]; }
|
|
2074
|
-
);
|
|
2075
|
-
};
|
|
2076
|
-
|
|
2077
2348
|
Map.prototype.sort = function sort (comparator) {
|
|
2078
2349
|
// Late binding
|
|
2079
2350
|
return OrderedMap(sortFactory(this, comparator));
|
|
@@ -2086,24 +2357,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
2086
2357
|
|
|
2087
2358
|
// @pragma Mutability
|
|
2088
2359
|
|
|
2089
|
-
Map.prototype.withMutations = function withMutations (fn) {
|
|
2090
|
-
var mutable = this.asMutable();
|
|
2091
|
-
fn(mutable);
|
|
2092
|
-
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
|
|
2093
|
-
};
|
|
2094
|
-
|
|
2095
|
-
Map.prototype.asMutable = function asMutable () {
|
|
2096
|
-
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
|
|
2097
|
-
};
|
|
2098
|
-
|
|
2099
|
-
Map.prototype.asImmutable = function asImmutable () {
|
|
2100
|
-
return this.__ensureOwner();
|
|
2101
|
-
};
|
|
2102
|
-
|
|
2103
|
-
Map.prototype.wasAltered = function wasAltered () {
|
|
2104
|
-
return this.__altered;
|
|
2105
|
-
};
|
|
2106
|
-
|
|
2107
2360
|
Map.prototype.__iterator = function __iterator (type, reverse) {
|
|
2108
2361
|
return new MapIterator(this, type, reverse);
|
|
2109
2362
|
};
|
|
@@ -2149,9 +2402,22 @@ var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
|
2149
2402
|
var MapPrototype = Map.prototype;
|
|
2150
2403
|
MapPrototype[IS_MAP_SENTINEL] = true;
|
|
2151
2404
|
MapPrototype[DELETE] = MapPrototype.remove;
|
|
2152
|
-
MapPrototype.removeIn = MapPrototype.deleteIn;
|
|
2153
2405
|
MapPrototype.removeAll = MapPrototype.deleteAll;
|
|
2154
|
-
MapPrototype
|
|
2406
|
+
MapPrototype.concat = MapPrototype.merge;
|
|
2407
|
+
MapPrototype.setIn = setIn$$1;
|
|
2408
|
+
MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
|
|
2409
|
+
MapPrototype.update = update$$1;
|
|
2410
|
+
MapPrototype.updateIn = updateIn$1;
|
|
2411
|
+
MapPrototype.merge = merge;
|
|
2412
|
+
MapPrototype.mergeWith = mergeWith;
|
|
2413
|
+
MapPrototype.mergeDeep = mergeDeep;
|
|
2414
|
+
MapPrototype.mergeDeepWith = mergeDeepWith;
|
|
2415
|
+
MapPrototype.mergeIn = mergeIn;
|
|
2416
|
+
MapPrototype.mergeDeepIn = mergeDeepIn;
|
|
2417
|
+
MapPrototype.withMutations = withMutations;
|
|
2418
|
+
MapPrototype.wasAltered = wasAltered;
|
|
2419
|
+
MapPrototype.asImmutable = asImmutable;
|
|
2420
|
+
MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
|
|
2155
2421
|
MapPrototype['@@transducer/step'] = function(result, arr) {
|
|
2156
2422
|
return result.set(arr[0], arr[1]);
|
|
2157
2423
|
};
|
|
@@ -2176,7 +2442,7 @@ ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
|
|
|
2176
2442
|
return notSetValue;
|
|
2177
2443
|
};
|
|
2178
2444
|
|
|
2179
|
-
ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2445
|
+
ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2180
2446
|
var removed = value === NOT_SET;
|
|
2181
2447
|
|
|
2182
2448
|
var entries = this.entries;
|
|
@@ -2249,7 +2515,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue
|
|
|
2249
2515
|
);
|
|
2250
2516
|
};
|
|
2251
2517
|
|
|
2252
|
-
BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2518
|
+
BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2253
2519
|
if (keyHash === undefined) {
|
|
2254
2520
|
keyHash = hash(key);
|
|
2255
2521
|
}
|
|
@@ -2301,7 +2567,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k
|
|
|
2301
2567
|
var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
|
|
2302
2568
|
var newNodes = exists
|
|
2303
2569
|
? newNode
|
|
2304
|
-
?
|
|
2570
|
+
? setAt(nodes, idx, newNode, isEditable)
|
|
2305
2571
|
: spliceOut(nodes, idx, isEditable)
|
|
2306
2572
|
: spliceIn(nodes, idx, newNode, isEditable);
|
|
2307
2573
|
|
|
@@ -2331,7 +2597,7 @@ HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue)
|
|
|
2331
2597
|
: notSetValue;
|
|
2332
2598
|
};
|
|
2333
2599
|
|
|
2334
|
-
HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2600
|
+
HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2335
2601
|
if (keyHash === undefined) {
|
|
2336
2602
|
keyHash = hash(key);
|
|
2337
2603
|
}
|
|
@@ -2369,7 +2635,7 @@ HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, ke
|
|
|
2369
2635
|
}
|
|
2370
2636
|
|
|
2371
2637
|
var isEditable = ownerID && ownerID === this.ownerID;
|
|
2372
|
-
var newNodes =
|
|
2638
|
+
var newNodes = setAt(nodes, idx, newNode, isEditable);
|
|
2373
2639
|
|
|
2374
2640
|
if (isEditable) {
|
|
2375
2641
|
this.count = newCount;
|
|
@@ -2396,7 +2662,7 @@ HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue
|
|
|
2396
2662
|
return notSetValue;
|
|
2397
2663
|
};
|
|
2398
2664
|
|
|
2399
|
-
HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2665
|
+
HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2400
2666
|
if (keyHash === undefined) {
|
|
2401
2667
|
keyHash = hash(key);
|
|
2402
2668
|
}
|
|
@@ -2466,7 +2732,7 @@ ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
|
|
|
2466
2732
|
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
|
|
2467
2733
|
};
|
|
2468
2734
|
|
|
2469
|
-
ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2735
|
+
ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2470
2736
|
var removed = value === NOT_SET;
|
|
2471
2737
|
var keyMatch = is(key, this.entry[0]);
|
|
2472
2738
|
if (keyMatch ? value === this.entry[1] : removed) {
|
|
@@ -2730,90 +2996,6 @@ function expandNodes(ownerID, nodes, bitmap, including, node) {
|
|
|
2730
2996
|
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
|
|
2731
2997
|
}
|
|
2732
2998
|
|
|
2733
|
-
function mergeIntoMapWith(map, merger, collections) {
|
|
2734
|
-
var iters = [];
|
|
2735
|
-
for (var ii = 0; ii < collections.length; ii++) {
|
|
2736
|
-
iters.push(KeyedCollection(collections[ii]));
|
|
2737
|
-
}
|
|
2738
|
-
return mergeIntoCollectionWith(map, merger, iters);
|
|
2739
|
-
}
|
|
2740
|
-
|
|
2741
|
-
function alwaysNewVal(oldVal, newVal) {
|
|
2742
|
-
return newVal;
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
function deepMergerWith(merger) {
|
|
2746
|
-
return function(oldVal, newVal, key) {
|
|
2747
|
-
if (oldVal && newVal && typeof newVal === 'object') {
|
|
2748
|
-
if (oldVal.mergeDeepWith) {
|
|
2749
|
-
return oldVal.mergeDeepWith(merger, newVal);
|
|
2750
|
-
}
|
|
2751
|
-
if (oldVal.merge) {
|
|
2752
|
-
return oldVal.merge(newVal);
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
var nextValue = merger(oldVal, newVal, key);
|
|
2756
|
-
return is(oldVal, nextValue) ? oldVal : nextValue;
|
|
2757
|
-
};
|
|
2758
|
-
}
|
|
2759
|
-
|
|
2760
|
-
function mergeIntoCollectionWith(collection, merger, iters) {
|
|
2761
|
-
iters = iters.filter(function (x) { return x.size !== 0; });
|
|
2762
|
-
if (iters.length === 0) {
|
|
2763
|
-
return collection;
|
|
2764
|
-
}
|
|
2765
|
-
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
|
|
2766
|
-
return collection.constructor(iters[0]);
|
|
2767
|
-
}
|
|
2768
|
-
return collection.withMutations(function (collection) {
|
|
2769
|
-
var mergeIntoCollection = merger
|
|
2770
|
-
? function (value, key) {
|
|
2771
|
-
collection.update(
|
|
2772
|
-
key,
|
|
2773
|
-
NOT_SET,
|
|
2774
|
-
function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
|
|
2775
|
-
);
|
|
2776
|
-
}
|
|
2777
|
-
: function (value, key) {
|
|
2778
|
-
collection.set(key, value);
|
|
2779
|
-
};
|
|
2780
|
-
for (var ii = 0; ii < iters.length; ii++) {
|
|
2781
|
-
iters[ii].forEach(mergeIntoCollection);
|
|
2782
|
-
}
|
|
2783
|
-
});
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
function updateInDeepMap(existing, keyPath, i, notSetValue, updater) {
|
|
2787
|
-
var isNotSet = existing === NOT_SET;
|
|
2788
|
-
if (i === keyPath.length) {
|
|
2789
|
-
var existingValue = isNotSet ? notSetValue : existing;
|
|
2790
|
-
var newValue = updater(existingValue);
|
|
2791
|
-
return newValue === existingValue ? existing : newValue;
|
|
2792
|
-
}
|
|
2793
|
-
if (!(isNotSet || (existing && existing.set))) {
|
|
2794
|
-
throw new TypeError(
|
|
2795
|
-
'Invalid keyPath: Value at [' +
|
|
2796
|
-
keyPath.slice(0, i).map(quoteString) +
|
|
2797
|
-
'] does not have a .set() method and cannot be updated: ' +
|
|
2798
|
-
existing
|
|
2799
|
-
);
|
|
2800
|
-
}
|
|
2801
|
-
var key = keyPath[i];
|
|
2802
|
-
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
|
|
2803
|
-
var nextUpdated = updateInDeepMap(
|
|
2804
|
-
nextExisting,
|
|
2805
|
-
keyPath,
|
|
2806
|
-
i + 1,
|
|
2807
|
-
notSetValue,
|
|
2808
|
-
updater
|
|
2809
|
-
);
|
|
2810
|
-
return nextUpdated === nextExisting
|
|
2811
|
-
? existing
|
|
2812
|
-
: nextUpdated === NOT_SET
|
|
2813
|
-
? existing.remove(key)
|
|
2814
|
-
: (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
2999
|
function popCount(x) {
|
|
2818
3000
|
x -= (x >> 1) & 0x55555555;
|
|
2819
3001
|
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
|
@@ -2823,7 +3005,7 @@ function popCount(x) {
|
|
|
2823
3005
|
return x & 0x7f;
|
|
2824
3006
|
}
|
|
2825
3007
|
|
|
2826
|
-
function
|
|
3008
|
+
function setAt(array, idx, val, canEdit) {
|
|
2827
3009
|
var newArray = canEdit ? array : arrCopy(array);
|
|
2828
3010
|
newArray[idx] = val;
|
|
2829
3011
|
return newArray;
|
|
@@ -2981,8 +3163,30 @@ var List = (function (IndexedCollection$$1) {
|
|
|
2981
3163
|
|
|
2982
3164
|
// @pragma Composition
|
|
2983
3165
|
|
|
2984
|
-
List.prototype.
|
|
2985
|
-
|
|
3166
|
+
List.prototype.concat = function concat (/*...collections*/) {
|
|
3167
|
+
var arguments$1 = arguments;
|
|
3168
|
+
|
|
3169
|
+
var seqs = [];
|
|
3170
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
3171
|
+
var argument = arguments$1[i];
|
|
3172
|
+
var seq = IndexedCollection$$1(
|
|
3173
|
+
typeof argument !== 'string' && hasIterator(argument)
|
|
3174
|
+
? argument
|
|
3175
|
+
: [argument]
|
|
3176
|
+
);
|
|
3177
|
+
if (seq.size !== 0) {
|
|
3178
|
+
seqs.push(seq);
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
if (seqs.length === 0) {
|
|
3182
|
+
return this;
|
|
3183
|
+
}
|
|
3184
|
+
if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
|
|
3185
|
+
return this.constructor(seqs[0]);
|
|
3186
|
+
}
|
|
3187
|
+
return this.withMutations(function (list) {
|
|
3188
|
+
seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
|
|
3189
|
+
});
|
|
2986
3190
|
};
|
|
2987
3191
|
|
|
2988
3192
|
List.prototype.setSize = function setSize (size) {
|
|
@@ -3065,21 +3269,23 @@ var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
|
3065
3269
|
var ListPrototype = List.prototype;
|
|
3066
3270
|
ListPrototype[IS_LIST_SENTINEL] = true;
|
|
3067
3271
|
ListPrototype[DELETE] = ListPrototype.remove;
|
|
3068
|
-
ListPrototype.
|
|
3069
|
-
ListPrototype.
|
|
3070
|
-
ListPrototype.
|
|
3071
|
-
ListPrototype.
|
|
3072
|
-
ListPrototype.
|
|
3073
|
-
ListPrototype.
|
|
3074
|
-
ListPrototype.
|
|
3075
|
-
ListPrototype.
|
|
3076
|
-
ListPrototype.
|
|
3077
|
-
ListPrototype.
|
|
3078
|
-
ListPrototype['@@transducer/init'] = ListPrototype.asMutable;
|
|
3272
|
+
ListPrototype.merge = ListPrototype.concat;
|
|
3273
|
+
ListPrototype.setIn = setIn$$1;
|
|
3274
|
+
ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
|
|
3275
|
+
ListPrototype.update = update$$1;
|
|
3276
|
+
ListPrototype.updateIn = updateIn$1;
|
|
3277
|
+
ListPrototype.mergeIn = mergeIn;
|
|
3278
|
+
ListPrototype.mergeDeepIn = mergeDeepIn;
|
|
3279
|
+
ListPrototype.withMutations = withMutations;
|
|
3280
|
+
ListPrototype.wasAltered = wasAltered;
|
|
3281
|
+
ListPrototype.asImmutable = asImmutable;
|
|
3282
|
+
ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
|
|
3079
3283
|
ListPrototype['@@transducer/step'] = function(result, arr) {
|
|
3080
3284
|
return result.push(arr);
|
|
3081
3285
|
};
|
|
3082
|
-
ListPrototype['@@transducer/result'] =
|
|
3286
|
+
ListPrototype['@@transducer/result'] = function(obj) {
|
|
3287
|
+
return obj.asImmutable();
|
|
3288
|
+
};
|
|
3083
3289
|
|
|
3084
3290
|
var VNode = function VNode(array, ownerID) {
|
|
3085
3291
|
this.array = array;
|
|
@@ -3852,18 +4058,19 @@ var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
|
3852
4058
|
|
|
3853
4059
|
var StackPrototype = Stack.prototype;
|
|
3854
4060
|
StackPrototype[IS_STACK_SENTINEL] = true;
|
|
3855
|
-
StackPrototype.withMutations = MapPrototype.withMutations;
|
|
3856
|
-
StackPrototype.asMutable = MapPrototype.asMutable;
|
|
3857
|
-
StackPrototype.asImmutable = MapPrototype.asImmutable;
|
|
3858
|
-
StackPrototype.wasAltered = MapPrototype.wasAltered;
|
|
3859
4061
|
StackPrototype.shift = StackPrototype.pop;
|
|
3860
4062
|
StackPrototype.unshift = StackPrototype.push;
|
|
3861
4063
|
StackPrototype.unshiftAll = StackPrototype.pushAll;
|
|
3862
|
-
StackPrototype
|
|
4064
|
+
StackPrototype.withMutations = withMutations;
|
|
4065
|
+
StackPrototype.wasAltered = wasAltered;
|
|
4066
|
+
StackPrototype.asImmutable = asImmutable;
|
|
4067
|
+
StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
|
|
3863
4068
|
StackPrototype['@@transducer/step'] = function(result, arr) {
|
|
3864
4069
|
return result.unshift(arr);
|
|
3865
4070
|
};
|
|
3866
|
-
StackPrototype['@@transducer/result'] =
|
|
4071
|
+
StackPrototype['@@transducer/result'] = function(obj) {
|
|
4072
|
+
return obj.asImmutable();
|
|
4073
|
+
};
|
|
3867
4074
|
|
|
3868
4075
|
function makeStack(size, head, ownerID, hash) {
|
|
3869
4076
|
var map = Object.create(StackPrototype);
|
|
@@ -3957,6 +4164,14 @@ function mixin(ctor, methods) {
|
|
|
3957
4164
|
return ctor;
|
|
3958
4165
|
}
|
|
3959
4166
|
|
|
4167
|
+
function toJS(value) {
|
|
4168
|
+
return isDataStructure(value)
|
|
4169
|
+
? Seq(value)
|
|
4170
|
+
.map(toJS)
|
|
4171
|
+
.toJSON()
|
|
4172
|
+
: value;
|
|
4173
|
+
}
|
|
4174
|
+
|
|
3960
4175
|
var Set = (function (SetCollection$$1) {
|
|
3961
4176
|
function Set(value) {
|
|
3962
4177
|
return value === null || value === undefined
|
|
@@ -4136,15 +4351,16 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
|
4136
4351
|
var SetPrototype = Set.prototype;
|
|
4137
4352
|
SetPrototype[IS_SET_SENTINEL] = true;
|
|
4138
4353
|
SetPrototype[DELETE] = SetPrototype.remove;
|
|
4139
|
-
SetPrototype.merge = SetPrototype.union;
|
|
4140
|
-
SetPrototype.withMutations =
|
|
4141
|
-
SetPrototype.
|
|
4142
|
-
SetPrototype.
|
|
4143
|
-
SetPrototype['@@transducer/init'] = SetPrototype.asMutable;
|
|
4354
|
+
SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
|
|
4355
|
+
SetPrototype.withMutations = withMutations;
|
|
4356
|
+
SetPrototype.asImmutable = asImmutable;
|
|
4357
|
+
SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
|
|
4144
4358
|
SetPrototype['@@transducer/step'] = function(result, arr) {
|
|
4145
4359
|
return result.add(arr);
|
|
4146
4360
|
};
|
|
4147
|
-
SetPrototype['@@transducer/result'] =
|
|
4361
|
+
SetPrototype['@@transducer/result'] = function(obj) {
|
|
4362
|
+
return obj.asImmutable();
|
|
4363
|
+
};
|
|
4148
4364
|
|
|
4149
4365
|
SetPrototype.__empty = emptySet;
|
|
4150
4366
|
SetPrototype.__make = makeSet;
|
|
@@ -4312,6 +4528,39 @@ var Range = (function (IndexedSeq$$1) {
|
|
|
4312
4528
|
|
|
4313
4529
|
var EMPTY_RANGE;
|
|
4314
4530
|
|
|
4531
|
+
function getIn$1(collection, searchKeyPath, notSetValue) {
|
|
4532
|
+
var keyPath = coerceKeyPath(searchKeyPath);
|
|
4533
|
+
var i = 0;
|
|
4534
|
+
while (i !== keyPath.length) {
|
|
4535
|
+
collection = get(collection, keyPath[i++], NOT_SET);
|
|
4536
|
+
if (collection === NOT_SET) {
|
|
4537
|
+
return notSetValue;
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
return collection;
|
|
4541
|
+
}
|
|
4542
|
+
|
|
4543
|
+
function getIn$$1(searchKeyPath, notSetValue) {
|
|
4544
|
+
return getIn$1(this, searchKeyPath, notSetValue);
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4547
|
+
function hasIn$1(collection, keyPath) {
|
|
4548
|
+
return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
|
|
4549
|
+
}
|
|
4550
|
+
|
|
4551
|
+
function hasIn$$1(searchKeyPath) {
|
|
4552
|
+
return hasIn$1(this, searchKeyPath);
|
|
4553
|
+
}
|
|
4554
|
+
|
|
4555
|
+
function toObject() {
|
|
4556
|
+
assertNotInfinite(this.size);
|
|
4557
|
+
var object = {};
|
|
4558
|
+
this.__iterate(function (v, k) {
|
|
4559
|
+
object[k] = v;
|
|
4560
|
+
});
|
|
4561
|
+
return object;
|
|
4562
|
+
}
|
|
4563
|
+
|
|
4315
4564
|
// Note: all of these methods are deprecated.
|
|
4316
4565
|
Collection.isIterable = isCollection;
|
|
4317
4566
|
Collection.isKeyed = isKeyed;
|
|
@@ -4341,9 +4590,7 @@ mixin(Collection, {
|
|
|
4341
4590
|
},
|
|
4342
4591
|
|
|
4343
4592
|
toJS: function toJS$1() {
|
|
4344
|
-
return this
|
|
4345
|
-
.map(toJS)
|
|
4346
|
-
.toJSON();
|
|
4593
|
+
return toJS(this);
|
|
4347
4594
|
},
|
|
4348
4595
|
|
|
4349
4596
|
toKeyedSeq: function toKeyedSeq() {
|
|
@@ -4355,14 +4602,7 @@ mixin(Collection, {
|
|
|
4355
4602
|
return Map(this.toKeyedSeq());
|
|
4356
4603
|
},
|
|
4357
4604
|
|
|
4358
|
-
toObject:
|
|
4359
|
-
assertNotInfinite(this.size);
|
|
4360
|
-
var object = {};
|
|
4361
|
-
this.__iterate(function (v, k) {
|
|
4362
|
-
object[k] = v;
|
|
4363
|
-
});
|
|
4364
|
-
return object;
|
|
4365
|
-
},
|
|
4605
|
+
toObject: toObject,
|
|
4366
4606
|
|
|
4367
4607
|
toOrderedMap: function toOrderedMap() {
|
|
4368
4608
|
// Use Late Binding here to solve the circular dependency.
|
|
@@ -4560,13 +4800,6 @@ mixin(Collection, {
|
|
|
4560
4800
|
.map(entryMapper)
|
|
4561
4801
|
.toIndexedSeq();
|
|
4562
4802
|
entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
|
|
4563
|
-
|
|
4564
|
-
// Entries are plain Array, which do not define toJS, so it must
|
|
4565
|
-
// manually converts keys and values before conversion.
|
|
4566
|
-
entriesSequence.toJS = function() {
|
|
4567
|
-
return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON();
|
|
4568
|
-
};
|
|
4569
|
-
|
|
4570
4803
|
return entriesSequence;
|
|
4571
4804
|
},
|
|
4572
4805
|
|
|
@@ -4628,9 +4861,7 @@ mixin(Collection, {
|
|
|
4628
4861
|
return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
|
|
4629
4862
|
},
|
|
4630
4863
|
|
|
4631
|
-
getIn:
|
|
4632
|
-
return getIn(this, notSetValue, searchKeyPath, true /* report bad path */);
|
|
4633
|
-
},
|
|
4864
|
+
getIn: getIn$$1,
|
|
4634
4865
|
|
|
4635
4866
|
groupBy: function groupBy(grouper, context) {
|
|
4636
4867
|
return groupByFactory(this, grouper, context);
|
|
@@ -4640,12 +4871,7 @@ mixin(Collection, {
|
|
|
4640
4871
|
return this.get(searchKey, NOT_SET) !== NOT_SET;
|
|
4641
4872
|
},
|
|
4642
4873
|
|
|
4643
|
-
hasIn:
|
|
4644
|
-
return (
|
|
4645
|
-
getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !==
|
|
4646
|
-
NOT_SET
|
|
4647
|
-
);
|
|
4648
|
-
},
|
|
4874
|
+
hasIn: hasIn$$1,
|
|
4649
4875
|
|
|
4650
4876
|
isSubset: function isSubset(iter) {
|
|
4651
4877
|
iter = typeof iter.includes === 'function' ? iter : Collection(iter);
|
|
@@ -4809,7 +5035,7 @@ mixin(KeyedCollection, {
|
|
|
4809
5035
|
var KeyedCollectionPrototype = KeyedCollection.prototype;
|
|
4810
5036
|
KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true;
|
|
4811
5037
|
KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
|
|
4812
|
-
KeyedCollectionPrototype.toJSON =
|
|
5038
|
+
KeyedCollectionPrototype.toJSON = toObject;
|
|
4813
5039
|
KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
|
|
4814
5040
|
|
|
4815
5041
|
mixin(IndexedCollection, {
|
|
@@ -4997,10 +5223,6 @@ function entryMapper(v, k) {
|
|
|
4997
5223
|
return [k, v];
|
|
4998
5224
|
}
|
|
4999
5225
|
|
|
5000
|
-
function toJS(value) {
|
|
5001
|
-
return value && typeof value.toJS === 'function' ? value.toJS() : value;
|
|
5002
|
-
}
|
|
5003
|
-
|
|
5004
5226
|
function not(predicate) {
|
|
5005
5227
|
return function() {
|
|
5006
5228
|
return !predicate.apply(this, arguments);
|
|
@@ -5063,40 +5285,6 @@ function hashMerge(a, b) {
|
|
|
5063
5285
|
return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
|
|
5064
5286
|
}
|
|
5065
5287
|
|
|
5066
|
-
function warn(message) {
|
|
5067
|
-
/* eslint-disable no-console */
|
|
5068
|
-
if (typeof console === 'object' && console.warn) {
|
|
5069
|
-
console.warn(message);
|
|
5070
|
-
} else {
|
|
5071
|
-
throw new Error(message);
|
|
5072
|
-
}
|
|
5073
|
-
/* eslint-enable no-console */
|
|
5074
|
-
}
|
|
5075
|
-
|
|
5076
|
-
function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) {
|
|
5077
|
-
var keyPath = coerceKeyPath(searchKeyPath);
|
|
5078
|
-
var i = 0;
|
|
5079
|
-
while (i !== keyPath.length) {
|
|
5080
|
-
if (!value || !value.get) {
|
|
5081
|
-
if (reportBadKeyPath) {
|
|
5082
|
-
warn(
|
|
5083
|
-
'Invalid keyPath: Value at [' +
|
|
5084
|
-
keyPath.slice(0, i).map(quoteString) +
|
|
5085
|
-
'] does not have a .get() method: ' +
|
|
5086
|
-
value +
|
|
5087
|
-
'\nThis warning will throw in a future version'
|
|
5088
|
-
);
|
|
5089
|
-
}
|
|
5090
|
-
return notSetValue;
|
|
5091
|
-
}
|
|
5092
|
-
value = value.get(keyPath[i++], NOT_SET);
|
|
5093
|
-
if (value === NOT_SET) {
|
|
5094
|
-
return notSetValue;
|
|
5095
|
-
}
|
|
5096
|
-
}
|
|
5097
|
-
return value;
|
|
5098
|
-
}
|
|
5099
|
-
|
|
5100
5288
|
var OrderedSet = (function (Set$$1) {
|
|
5101
5289
|
function OrderedSet(value) {
|
|
5102
5290
|
return value === null || value === undefined
|
|
@@ -5287,8 +5475,12 @@ Record.prototype.toSeq = function toSeq () {
|
|
|
5287
5475
|
return recordSeq(this);
|
|
5288
5476
|
};
|
|
5289
5477
|
|
|
5290
|
-
Record.prototype.toJS = function toJS () {
|
|
5291
|
-
return
|
|
5478
|
+
Record.prototype.toJS = function toJS$1 () {
|
|
5479
|
+
return toJS(this);
|
|
5480
|
+
};
|
|
5481
|
+
|
|
5482
|
+
Record.prototype.entries = function entries () {
|
|
5483
|
+
return this.__iterator(ITERATE_ENTRIES);
|
|
5292
5484
|
};
|
|
5293
5485
|
|
|
5294
5486
|
Record.prototype.__iterator = function __iterator (type, reverse) {
|
|
@@ -5317,26 +5509,27 @@ Record.getDescriptiveName = recordName;
|
|
|
5317
5509
|
var RecordPrototype = Record.prototype;
|
|
5318
5510
|
RecordPrototype[IS_RECORD_SENTINEL] = true;
|
|
5319
5511
|
RecordPrototype[DELETE] = RecordPrototype.remove;
|
|
5320
|
-
RecordPrototype.deleteIn = RecordPrototype.removeIn =
|
|
5321
|
-
RecordPrototype.getIn =
|
|
5512
|
+
RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
|
|
5513
|
+
RecordPrototype.getIn = getIn$$1;
|
|
5322
5514
|
RecordPrototype.hasIn = CollectionPrototype.hasIn;
|
|
5323
|
-
RecordPrototype.merge =
|
|
5324
|
-
RecordPrototype.mergeWith =
|
|
5325
|
-
RecordPrototype.mergeIn =
|
|
5326
|
-
RecordPrototype.mergeDeep =
|
|
5327
|
-
RecordPrototype.mergeDeepWith =
|
|
5328
|
-
RecordPrototype.mergeDeepIn =
|
|
5329
|
-
RecordPrototype.setIn =
|
|
5330
|
-
RecordPrototype.update =
|
|
5331
|
-
RecordPrototype.updateIn =
|
|
5332
|
-
RecordPrototype.withMutations =
|
|
5333
|
-
RecordPrototype.asMutable =
|
|
5334
|
-
RecordPrototype.asImmutable =
|
|
5335
|
-
RecordPrototype[ITERATOR_SYMBOL] =
|
|
5515
|
+
RecordPrototype.merge = merge;
|
|
5516
|
+
RecordPrototype.mergeWith = mergeWith;
|
|
5517
|
+
RecordPrototype.mergeIn = mergeIn;
|
|
5518
|
+
RecordPrototype.mergeDeep = mergeDeep;
|
|
5519
|
+
RecordPrototype.mergeDeepWith = mergeDeepWith;
|
|
5520
|
+
RecordPrototype.mergeDeepIn = mergeDeepIn;
|
|
5521
|
+
RecordPrototype.setIn = setIn$$1;
|
|
5522
|
+
RecordPrototype.update = update$$1;
|
|
5523
|
+
RecordPrototype.updateIn = updateIn$1;
|
|
5524
|
+
RecordPrototype.withMutations = withMutations;
|
|
5525
|
+
RecordPrototype.asMutable = asMutable;
|
|
5526
|
+
RecordPrototype.asImmutable = asImmutable;
|
|
5527
|
+
RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
|
|
5336
5528
|
RecordPrototype.toJSON = RecordPrototype.toObject =
|
|
5337
5529
|
CollectionPrototype.toObject;
|
|
5338
|
-
RecordPrototype.inspect = RecordPrototype.toSource =
|
|
5339
|
-
|
|
5530
|
+
RecordPrototype.inspect = RecordPrototype.toSource = function() {
|
|
5531
|
+
return this.toString();
|
|
5532
|
+
};
|
|
5340
5533
|
|
|
5341
5534
|
function makeRecord(likeRecord, values, ownerID) {
|
|
5342
5535
|
var record = Object.create(Object.getPrototypeOf(likeRecord));
|
|
@@ -5510,14 +5703,9 @@ function defaultConverter(k, v) {
|
|
|
5510
5703
|
return isKeyed(v) ? v.toMap() : v.toList();
|
|
5511
5704
|
}
|
|
5512
5705
|
|
|
5513
|
-
|
|
5514
|
-
return (
|
|
5515
|
-
value && (value.constructor === Object || value.constructor === undefined)
|
|
5516
|
-
);
|
|
5517
|
-
}
|
|
5518
|
-
|
|
5519
|
-
var version = "4.0.0-rc.5";
|
|
5706
|
+
var version = "4.0.0-rc.9";
|
|
5520
5707
|
|
|
5708
|
+
// Functional read/write API
|
|
5521
5709
|
var Immutable = {
|
|
5522
5710
|
version: version,
|
|
5523
5711
|
|
|
@@ -5547,7 +5735,22 @@ var Immutable = {
|
|
|
5547
5735
|
isIndexed: isIndexed,
|
|
5548
5736
|
isAssociative: isAssociative,
|
|
5549
5737
|
isOrdered: isOrdered,
|
|
5550
|
-
isValueObject: isValueObject
|
|
5738
|
+
isValueObject: isValueObject,
|
|
5739
|
+
|
|
5740
|
+
get: get,
|
|
5741
|
+
getIn: getIn$1,
|
|
5742
|
+
has: has,
|
|
5743
|
+
hasIn: hasIn$1,
|
|
5744
|
+
merge: merge$1,
|
|
5745
|
+
mergeDeep: mergeDeep$1,
|
|
5746
|
+
mergeWith: mergeWith$1,
|
|
5747
|
+
mergeDeepWith: mergeDeepWith$1,
|
|
5748
|
+
remove: remove,
|
|
5749
|
+
removeIn: removeIn,
|
|
5750
|
+
set: set,
|
|
5751
|
+
setIn: setIn$1,
|
|
5752
|
+
update: update$1,
|
|
5753
|
+
updateIn: updateIn
|
|
5551
5754
|
};
|
|
5552
5755
|
|
|
5553
5756
|
// Note: Iterable is deprecated
|
|
@@ -5577,6 +5780,20 @@ exports.isIndexed = isIndexed;
|
|
|
5577
5780
|
exports.isAssociative = isAssociative;
|
|
5578
5781
|
exports.isOrdered = isOrdered;
|
|
5579
5782
|
exports.isValueObject = isValueObject;
|
|
5783
|
+
exports.get = get;
|
|
5784
|
+
exports.getIn = getIn$1;
|
|
5785
|
+
exports.has = has;
|
|
5786
|
+
exports.hasIn = hasIn$1;
|
|
5787
|
+
exports.merge = merge$1;
|
|
5788
|
+
exports.mergeDeep = mergeDeep$1;
|
|
5789
|
+
exports.mergeWith = mergeWith$1;
|
|
5790
|
+
exports.mergeDeepWith = mergeDeepWith$1;
|
|
5791
|
+
exports.remove = remove;
|
|
5792
|
+
exports.removeIn = removeIn;
|
|
5793
|
+
exports.set = set;
|
|
5794
|
+
exports.setIn = setIn$1;
|
|
5795
|
+
exports.update = update$1;
|
|
5796
|
+
exports.updateIn = updateIn;
|
|
5580
5797
|
|
|
5581
5798
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5582
5799
|
|