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.es.js
CHANGED
|
@@ -35,17 +35,6 @@ function SetRef(ref) {
|
|
|
35
35
|
// the return of any subsequent call of this function.
|
|
36
36
|
function OwnerID() {}
|
|
37
37
|
|
|
38
|
-
// http://jsperf.com/copy-array-inline
|
|
39
|
-
function arrCopy(arr, offset) {
|
|
40
|
-
offset = offset || 0;
|
|
41
|
-
var len = Math.max(0, arr.length - offset);
|
|
42
|
-
var newArr = new Array(len);
|
|
43
|
-
for (var ii = 0; ii < len; ii++) {
|
|
44
|
-
newArr[ii] = arr[ii + offset];
|
|
45
|
-
}
|
|
46
|
-
return newArr;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
38
|
function ensureSize(iter) {
|
|
50
39
|
if (iter.size === undefined) {
|
|
51
40
|
iter.size = iter.__iterate(returnTrue);
|
|
@@ -109,10 +98,7 @@ function isNeg(value) {
|
|
|
109
98
|
}
|
|
110
99
|
|
|
111
100
|
function isImmutable(maybeImmutable) {
|
|
112
|
-
return (
|
|
113
|
-
(isCollection(maybeImmutable) || isRecord(maybeImmutable)) &&
|
|
114
|
-
!maybeImmutable.__ownerID
|
|
115
|
-
);
|
|
101
|
+
return isCollection(maybeImmutable) || isRecord(maybeImmutable);
|
|
116
102
|
}
|
|
117
103
|
|
|
118
104
|
function isCollection(maybeCollection) {
|
|
@@ -263,6 +249,8 @@ function getIteratorFn(iterable) {
|
|
|
263
249
|
}
|
|
264
250
|
}
|
|
265
251
|
|
|
252
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
253
|
+
|
|
266
254
|
function isArrayLike(value) {
|
|
267
255
|
return value && typeof value.length === 'number';
|
|
268
256
|
}
|
|
@@ -271,9 +259,7 @@ var Seq = (function (Collection$$1) {
|
|
|
271
259
|
function Seq(value) {
|
|
272
260
|
return value === null || value === undefined
|
|
273
261
|
? emptySequence()
|
|
274
|
-
:
|
|
275
|
-
? value.toSeq()
|
|
276
|
-
: seqFromValue(value);
|
|
262
|
+
: isImmutable(value) ? value.toSeq() : seqFromValue(value);
|
|
277
263
|
}
|
|
278
264
|
|
|
279
265
|
if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
|
|
@@ -486,7 +472,7 @@ var ObjectSeq = (function (KeyedSeq) {
|
|
|
486
472
|
};
|
|
487
473
|
|
|
488
474
|
ObjectSeq.prototype.has = function has (key) {
|
|
489
|
-
return this._object
|
|
475
|
+
return hasOwnProperty.call(this._object, key);
|
|
490
476
|
};
|
|
491
477
|
|
|
492
478
|
ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
|
|
@@ -1872,6 +1858,28 @@ function defaultComparator(a, b) {
|
|
|
1872
1858
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
1873
1859
|
}
|
|
1874
1860
|
|
|
1861
|
+
// http://jsperf.com/copy-array-inline
|
|
1862
|
+
function arrCopy(arr, offset) {
|
|
1863
|
+
offset = offset || 0;
|
|
1864
|
+
var len = Math.max(0, arr.length - offset);
|
|
1865
|
+
var newArr = new Array(len);
|
|
1866
|
+
for (var ii = 0; ii < len; ii++) {
|
|
1867
|
+
newArr[ii] = arr[ii + offset];
|
|
1868
|
+
}
|
|
1869
|
+
return newArr;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
function invariant(condition, error) {
|
|
1873
|
+
if (!condition) { throw new Error(error); }
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
function assertNotInfinite(size) {
|
|
1877
|
+
invariant(
|
|
1878
|
+
size !== Infinity,
|
|
1879
|
+
'Cannot perform this action with an infinite size.'
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1875
1883
|
function coerceKeyPath(keyPath) {
|
|
1876
1884
|
if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
|
|
1877
1885
|
return keyPath;
|
|
@@ -1884,15 +1892,18 @@ function coerceKeyPath(keyPath) {
|
|
|
1884
1892
|
);
|
|
1885
1893
|
}
|
|
1886
1894
|
|
|
1887
|
-
function
|
|
1888
|
-
|
|
1895
|
+
function isPlainObj(value) {
|
|
1896
|
+
return (
|
|
1897
|
+
value && (value.constructor === Object || value.constructor === undefined)
|
|
1898
|
+
);
|
|
1889
1899
|
}
|
|
1890
1900
|
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1901
|
+
/**
|
|
1902
|
+
* Returns true if the value is a potentially-persistent data structure, either
|
|
1903
|
+
* provided by Immutable.js or a plain Array or Object.
|
|
1904
|
+
*/
|
|
1905
|
+
function isDataStructure(value) {
|
|
1906
|
+
return isImmutable(value) || Array.isArray(value) || isPlainObj(value);
|
|
1896
1907
|
}
|
|
1897
1908
|
|
|
1898
1909
|
/**
|
|
@@ -1906,6 +1917,347 @@ function quoteString(value) {
|
|
|
1906
1917
|
}
|
|
1907
1918
|
}
|
|
1908
1919
|
|
|
1920
|
+
function has(collection, key) {
|
|
1921
|
+
return isImmutable(collection)
|
|
1922
|
+
? collection.has(key)
|
|
1923
|
+
: isDataStructure(collection) && hasOwnProperty.call(collection, key);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
function get(collection, key, notSetValue) {
|
|
1927
|
+
return isImmutable(collection)
|
|
1928
|
+
? collection.get(key, notSetValue)
|
|
1929
|
+
: !has(collection, key)
|
|
1930
|
+
? notSetValue
|
|
1931
|
+
: typeof collection.get === 'function'
|
|
1932
|
+
? collection.get(key)
|
|
1933
|
+
: collection[key];
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
function shallowCopy(from) {
|
|
1937
|
+
if (Array.isArray(from)) {
|
|
1938
|
+
return arrCopy(from);
|
|
1939
|
+
}
|
|
1940
|
+
var to = {};
|
|
1941
|
+
for (var key in from) {
|
|
1942
|
+
if (hasOwnProperty.call(from, key)) {
|
|
1943
|
+
to[key] = from[key];
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return to;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
function remove(collection, key) {
|
|
1950
|
+
if (!isDataStructure(collection)) {
|
|
1951
|
+
throw new TypeError(
|
|
1952
|
+
'Cannot update non-data-structure value: ' + collection
|
|
1953
|
+
);
|
|
1954
|
+
}
|
|
1955
|
+
if (isImmutable(collection)) {
|
|
1956
|
+
if (!collection.remove) {
|
|
1957
|
+
throw new TypeError(
|
|
1958
|
+
'Cannot update immutable value without .remove() method: ' + collection
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
return collection.remove(key);
|
|
1962
|
+
}
|
|
1963
|
+
if (!hasOwnProperty.call(collection, key)) {
|
|
1964
|
+
return collection;
|
|
1965
|
+
}
|
|
1966
|
+
var collectionCopy = shallowCopy(collection);
|
|
1967
|
+
if (Array.isArray(collectionCopy)) {
|
|
1968
|
+
collectionCopy.splice(key, 1);
|
|
1969
|
+
} else {
|
|
1970
|
+
delete collectionCopy[key];
|
|
1971
|
+
}
|
|
1972
|
+
return collectionCopy;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
function set(collection, key, value) {
|
|
1976
|
+
if (!isDataStructure(collection)) {
|
|
1977
|
+
throw new TypeError(
|
|
1978
|
+
'Cannot update non-data-structure value: ' + collection
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
if (isImmutable(collection)) {
|
|
1982
|
+
if (!collection.set) {
|
|
1983
|
+
throw new TypeError(
|
|
1984
|
+
'Cannot update immutable value without .set() method: ' + collection
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1987
|
+
return collection.set(key, value);
|
|
1988
|
+
}
|
|
1989
|
+
if (hasOwnProperty.call(collection, key) && value === collection[key]) {
|
|
1990
|
+
return collection;
|
|
1991
|
+
}
|
|
1992
|
+
var collectionCopy = shallowCopy(collection);
|
|
1993
|
+
collectionCopy[key] = value;
|
|
1994
|
+
return collectionCopy;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
function updateIn(collection, keyPath, notSetValue, updater) {
|
|
1998
|
+
if (!updater) {
|
|
1999
|
+
updater = notSetValue;
|
|
2000
|
+
notSetValue = undefined;
|
|
2001
|
+
}
|
|
2002
|
+
var updatedValue = updateInDeeply(
|
|
2003
|
+
isImmutable(collection),
|
|
2004
|
+
collection,
|
|
2005
|
+
coerceKeyPath(keyPath),
|
|
2006
|
+
0,
|
|
2007
|
+
notSetValue,
|
|
2008
|
+
updater
|
|
2009
|
+
);
|
|
2010
|
+
return updatedValue === NOT_SET ? notSetValue : updatedValue;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
function updateInDeeply(
|
|
2014
|
+
inImmutable,
|
|
2015
|
+
existing,
|
|
2016
|
+
keyPath,
|
|
2017
|
+
i,
|
|
2018
|
+
notSetValue,
|
|
2019
|
+
updater
|
|
2020
|
+
) {
|
|
2021
|
+
var wasNotSet = existing === NOT_SET;
|
|
2022
|
+
if (i === keyPath.length) {
|
|
2023
|
+
var existingValue = wasNotSet ? notSetValue : existing;
|
|
2024
|
+
var newValue = updater(existingValue);
|
|
2025
|
+
return newValue === existingValue ? existing : newValue;
|
|
2026
|
+
}
|
|
2027
|
+
if (!wasNotSet && !isDataStructure(existing)) {
|
|
2028
|
+
throw new TypeError(
|
|
2029
|
+
'Cannot update within non-data-structure value in path [' +
|
|
2030
|
+
keyPath.slice(0, i).map(quoteString) +
|
|
2031
|
+
']: ' +
|
|
2032
|
+
existing
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
var key = keyPath[i];
|
|
2036
|
+
var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
|
|
2037
|
+
var nextUpdated = updateInDeeply(
|
|
2038
|
+
nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
|
|
2039
|
+
nextExisting,
|
|
2040
|
+
keyPath,
|
|
2041
|
+
i + 1,
|
|
2042
|
+
notSetValue,
|
|
2043
|
+
updater
|
|
2044
|
+
);
|
|
2045
|
+
return nextUpdated === nextExisting
|
|
2046
|
+
? existing
|
|
2047
|
+
: nextUpdated === NOT_SET
|
|
2048
|
+
? remove(existing, key)
|
|
2049
|
+
: set(
|
|
2050
|
+
wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
|
|
2051
|
+
key,
|
|
2052
|
+
nextUpdated
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
function setIn$1(collection, keyPath, value) {
|
|
2057
|
+
return updateIn(collection, keyPath, NOT_SET, function () { return value; });
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
function setIn$$1(keyPath, v) {
|
|
2061
|
+
return setIn$1(this, keyPath, v);
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
function removeIn(collection, keyPath) {
|
|
2065
|
+
return updateIn(collection, keyPath, function () { return NOT_SET; });
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function deleteIn(keyPath) {
|
|
2069
|
+
return removeIn(this, keyPath);
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
function update$1(collection, key, notSetValue, updater) {
|
|
2073
|
+
return updateIn(collection, [key], notSetValue, updater);
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
function update$$1(key, notSetValue, updater) {
|
|
2077
|
+
return arguments.length === 1
|
|
2078
|
+
? key(this)
|
|
2079
|
+
: update$1(this, key, notSetValue, updater);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
function updateIn$1(keyPath, notSetValue, updater) {
|
|
2083
|
+
return updateIn(this, keyPath, notSetValue, updater);
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
function merge() {
|
|
2087
|
+
var iters = [], len = arguments.length;
|
|
2088
|
+
while ( len-- ) iters[ len ] = arguments[ len ];
|
|
2089
|
+
|
|
2090
|
+
return mergeIntoKeyedWith(this, iters);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
function mergeWith(merger) {
|
|
2094
|
+
var iters = [], len = arguments.length - 1;
|
|
2095
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2096
|
+
|
|
2097
|
+
return mergeIntoKeyedWith(this, iters, merger);
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
function mergeIntoKeyedWith(collection, collections, merger) {
|
|
2101
|
+
var iters = [];
|
|
2102
|
+
for (var ii = 0; ii < collections.length; ii++) {
|
|
2103
|
+
var collection$1 = KeyedCollection(collections[ii]);
|
|
2104
|
+
if (collection$1.size !== 0) {
|
|
2105
|
+
iters.push(collection$1);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
if (iters.length === 0) {
|
|
2109
|
+
return collection;
|
|
2110
|
+
}
|
|
2111
|
+
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
|
|
2112
|
+
return collection.constructor(iters[0]);
|
|
2113
|
+
}
|
|
2114
|
+
return collection.withMutations(function (collection) {
|
|
2115
|
+
var mergeIntoCollection = merger
|
|
2116
|
+
? function (value, key) {
|
|
2117
|
+
update$1(
|
|
2118
|
+
collection,
|
|
2119
|
+
key,
|
|
2120
|
+
NOT_SET,
|
|
2121
|
+
function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
|
|
2122
|
+
);
|
|
2123
|
+
}
|
|
2124
|
+
: function (value, key) {
|
|
2125
|
+
collection.set(key, value);
|
|
2126
|
+
};
|
|
2127
|
+
for (var ii = 0; ii < iters.length; ii++) {
|
|
2128
|
+
iters[ii].forEach(mergeIntoCollection);
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
function merge$1(collection) {
|
|
2134
|
+
var sources = [], len = arguments.length - 1;
|
|
2135
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
2136
|
+
|
|
2137
|
+
return mergeWithSources(collection, sources);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
function mergeWith$1(merger, collection) {
|
|
2141
|
+
var sources = [], len = arguments.length - 2;
|
|
2142
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
2143
|
+
|
|
2144
|
+
return mergeWithSources(collection, sources, merger);
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
function mergeDeep$1(collection) {
|
|
2148
|
+
var sources = [], len = arguments.length - 1;
|
|
2149
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
|
|
2150
|
+
|
|
2151
|
+
return mergeDeepWithSources(collection, sources);
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
function mergeDeepWith$1(merger, collection) {
|
|
2155
|
+
var sources = [], len = arguments.length - 2;
|
|
2156
|
+
while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
|
|
2157
|
+
|
|
2158
|
+
return mergeDeepWithSources(collection, sources, merger);
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
function mergeDeepWithSources(collection, sources, merger) {
|
|
2162
|
+
return mergeWithSources(collection, sources, deepMergerWith(merger));
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
function mergeWithSources(collection, sources, merger) {
|
|
2166
|
+
if (!isDataStructure(collection)) {
|
|
2167
|
+
throw new TypeError(
|
|
2168
|
+
'Cannot merge into non-data-structure value: ' + collection
|
|
2169
|
+
);
|
|
2170
|
+
}
|
|
2171
|
+
if (isImmutable(collection)) {
|
|
2172
|
+
return collection.mergeWith
|
|
2173
|
+
? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
|
|
2174
|
+
: collection.concat.apply(collection, sources);
|
|
2175
|
+
}
|
|
2176
|
+
var isArray = Array.isArray(collection);
|
|
2177
|
+
var merged = collection;
|
|
2178
|
+
var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
|
|
2179
|
+
var mergeItem = isArray
|
|
2180
|
+
? function (value) {
|
|
2181
|
+
// Copy on write
|
|
2182
|
+
if (merged === collection) {
|
|
2183
|
+
merged = shallowCopy(merged);
|
|
2184
|
+
}
|
|
2185
|
+
merged.push(value);
|
|
2186
|
+
}
|
|
2187
|
+
: function (value, key) {
|
|
2188
|
+
var hasVal = hasOwnProperty.call(merged, key);
|
|
2189
|
+
var nextVal =
|
|
2190
|
+
hasVal && merger ? merger(merged[key], value, key) : value;
|
|
2191
|
+
if (!hasVal || nextVal !== merged[key]) {
|
|
2192
|
+
// Copy on write
|
|
2193
|
+
if (merged === collection) {
|
|
2194
|
+
merged = shallowCopy(merged);
|
|
2195
|
+
}
|
|
2196
|
+
merged[key] = nextVal;
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
for (var i = 0; i < sources.length; i++) {
|
|
2200
|
+
Collection$$1(sources[i]).forEach(mergeItem);
|
|
2201
|
+
}
|
|
2202
|
+
return merged;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
function deepMergerWith(merger) {
|
|
2206
|
+
function deepMerger(oldValue, newValue, key) {
|
|
2207
|
+
return isDataStructure(oldValue) && isDataStructure(newValue)
|
|
2208
|
+
? mergeWithSources(oldValue, [newValue], deepMerger)
|
|
2209
|
+
: merger ? merger(oldValue, newValue, key) : newValue;
|
|
2210
|
+
}
|
|
2211
|
+
return deepMerger;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
function mergeDeep() {
|
|
2215
|
+
var iters = [], len = arguments.length;
|
|
2216
|
+
while ( len-- ) iters[ len ] = arguments[ len ];
|
|
2217
|
+
|
|
2218
|
+
return mergeDeepWithSources(this, iters);
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
function mergeDeepWith(merger) {
|
|
2222
|
+
var iters = [], len = arguments.length - 1;
|
|
2223
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2224
|
+
|
|
2225
|
+
return mergeDeepWithSources(this, iters, merger);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
function mergeIn(keyPath) {
|
|
2229
|
+
var iters = [], len = arguments.length - 1;
|
|
2230
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2231
|
+
|
|
2232
|
+
return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
function mergeDeepIn(keyPath) {
|
|
2236
|
+
var iters = [], len = arguments.length - 1;
|
|
2237
|
+
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2238
|
+
|
|
2239
|
+
return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
function withMutations(fn) {
|
|
2244
|
+
var mutable = this.asMutable();
|
|
2245
|
+
fn(mutable);
|
|
2246
|
+
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
function asMutable() {
|
|
2250
|
+
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
function asImmutable() {
|
|
2254
|
+
return this.__ensureOwner();
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
function wasAltered() {
|
|
2258
|
+
return this.__altered;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
1909
2261
|
var Map = (function (KeyedCollection$$1) {
|
|
1910
2262
|
function Map(value) {
|
|
1911
2263
|
return value === null || value === undefined
|
|
@@ -1955,22 +2307,10 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
1955
2307
|
return updateMap(this, k, v);
|
|
1956
2308
|
};
|
|
1957
2309
|
|
|
1958
|
-
Map.prototype.setIn = function setIn (keyPath, v) {
|
|
1959
|
-
return this.updateIn(keyPath, NOT_SET, function () { return v; });
|
|
1960
|
-
};
|
|
1961
|
-
|
|
1962
2310
|
Map.prototype.remove = function remove (k) {
|
|
1963
2311
|
return updateMap(this, k, NOT_SET);
|
|
1964
2312
|
};
|
|
1965
2313
|
|
|
1966
|
-
Map.prototype.deleteIn = function deleteIn (keyPath) {
|
|
1967
|
-
keyPath = [].concat( coerceKeyPath(keyPath) );
|
|
1968
|
-
if (keyPath.length) {
|
|
1969
|
-
var lastKey = keyPath.pop();
|
|
1970
|
-
return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); });
|
|
1971
|
-
}
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
2314
|
Map.prototype.deleteAll = function deleteAll (keys) {
|
|
1975
2315
|
var collection = Collection(keys);
|
|
1976
2316
|
|
|
@@ -1983,27 +2323,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
1983
2323
|
});
|
|
1984
2324
|
};
|
|
1985
2325
|
|
|
1986
|
-
Map.prototype.update = function update (k, notSetValue, updater) {
|
|
1987
|
-
return arguments.length === 1
|
|
1988
|
-
? k(this)
|
|
1989
|
-
: this.updateIn([k], notSetValue, updater);
|
|
1990
|
-
};
|
|
1991
|
-
|
|
1992
|
-
Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) {
|
|
1993
|
-
if (!updater) {
|
|
1994
|
-
updater = notSetValue;
|
|
1995
|
-
notSetValue = undefined;
|
|
1996
|
-
}
|
|
1997
|
-
var updatedValue = updateInDeepMap(
|
|
1998
|
-
this,
|
|
1999
|
-
coerceKeyPath(keyPath),
|
|
2000
|
-
0,
|
|
2001
|
-
notSetValue,
|
|
2002
|
-
updater
|
|
2003
|
-
);
|
|
2004
|
-
return updatedValue === NOT_SET ? notSetValue : updatedValue;
|
|
2005
|
-
};
|
|
2006
|
-
|
|
2007
2326
|
Map.prototype.clear = function clear () {
|
|
2008
2327
|
if (this.size === 0) {
|
|
2009
2328
|
return this;
|
|
@@ -2020,54 +2339,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
2020
2339
|
|
|
2021
2340
|
// @pragma Composition
|
|
2022
2341
|
|
|
2023
|
-
Map.prototype.merge = function merge (/*...iters*/) {
|
|
2024
|
-
return mergeIntoMapWith(this, undefined, arguments);
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
|
-
Map.prototype.mergeWith = function mergeWith (merger) {
|
|
2028
|
-
var iters = [], len = arguments.length - 1;
|
|
2029
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2030
|
-
|
|
2031
|
-
return mergeIntoMapWith(this, merger, iters);
|
|
2032
|
-
};
|
|
2033
|
-
|
|
2034
|
-
Map.prototype.mergeIn = function mergeIn (keyPath) {
|
|
2035
|
-
var iters = [], len = arguments.length - 1;
|
|
2036
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2037
|
-
|
|
2038
|
-
return this.updateIn(
|
|
2039
|
-
keyPath,
|
|
2040
|
-
emptyMap(),
|
|
2041
|
-
function (m) { return typeof m.merge === 'function'
|
|
2042
|
-
? m.merge.apply(m, iters)
|
|
2043
|
-
: iters[iters.length - 1]; }
|
|
2044
|
-
);
|
|
2045
|
-
};
|
|
2046
|
-
|
|
2047
|
-
Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) {
|
|
2048
|
-
return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments);
|
|
2049
|
-
};
|
|
2050
|
-
|
|
2051
|
-
Map.prototype.mergeDeepWith = function mergeDeepWith (merger) {
|
|
2052
|
-
var iters = [], len = arguments.length - 1;
|
|
2053
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2054
|
-
|
|
2055
|
-
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
|
|
2056
|
-
};
|
|
2057
|
-
|
|
2058
|
-
Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) {
|
|
2059
|
-
var iters = [], len = arguments.length - 1;
|
|
2060
|
-
while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
|
|
2061
|
-
|
|
2062
|
-
return this.updateIn(
|
|
2063
|
-
keyPath,
|
|
2064
|
-
emptyMap(),
|
|
2065
|
-
function (m) { return typeof m.mergeDeep === 'function'
|
|
2066
|
-
? m.mergeDeep.apply(m, iters)
|
|
2067
|
-
: iters[iters.length - 1]; }
|
|
2068
|
-
);
|
|
2069
|
-
};
|
|
2070
|
-
|
|
2071
2342
|
Map.prototype.sort = function sort (comparator) {
|
|
2072
2343
|
// Late binding
|
|
2073
2344
|
return OrderedMap(sortFactory(this, comparator));
|
|
@@ -2080,24 +2351,6 @@ var Map = (function (KeyedCollection$$1) {
|
|
|
2080
2351
|
|
|
2081
2352
|
// @pragma Mutability
|
|
2082
2353
|
|
|
2083
|
-
Map.prototype.withMutations = function withMutations (fn) {
|
|
2084
|
-
var mutable = this.asMutable();
|
|
2085
|
-
fn(mutable);
|
|
2086
|
-
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
Map.prototype.asMutable = function asMutable () {
|
|
2090
|
-
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
|
|
2091
|
-
};
|
|
2092
|
-
|
|
2093
|
-
Map.prototype.asImmutable = function asImmutable () {
|
|
2094
|
-
return this.__ensureOwner();
|
|
2095
|
-
};
|
|
2096
|
-
|
|
2097
|
-
Map.prototype.wasAltered = function wasAltered () {
|
|
2098
|
-
return this.__altered;
|
|
2099
|
-
};
|
|
2100
|
-
|
|
2101
2354
|
Map.prototype.__iterator = function __iterator (type, reverse) {
|
|
2102
2355
|
return new MapIterator(this, type, reverse);
|
|
2103
2356
|
};
|
|
@@ -2143,9 +2396,22 @@ var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
|
2143
2396
|
var MapPrototype = Map.prototype;
|
|
2144
2397
|
MapPrototype[IS_MAP_SENTINEL] = true;
|
|
2145
2398
|
MapPrototype[DELETE] = MapPrototype.remove;
|
|
2146
|
-
MapPrototype.removeIn = MapPrototype.deleteIn;
|
|
2147
2399
|
MapPrototype.removeAll = MapPrototype.deleteAll;
|
|
2148
|
-
MapPrototype
|
|
2400
|
+
MapPrototype.concat = MapPrototype.merge;
|
|
2401
|
+
MapPrototype.setIn = setIn$$1;
|
|
2402
|
+
MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
|
|
2403
|
+
MapPrototype.update = update$$1;
|
|
2404
|
+
MapPrototype.updateIn = updateIn$1;
|
|
2405
|
+
MapPrototype.merge = merge;
|
|
2406
|
+
MapPrototype.mergeWith = mergeWith;
|
|
2407
|
+
MapPrototype.mergeDeep = mergeDeep;
|
|
2408
|
+
MapPrototype.mergeDeepWith = mergeDeepWith;
|
|
2409
|
+
MapPrototype.mergeIn = mergeIn;
|
|
2410
|
+
MapPrototype.mergeDeepIn = mergeDeepIn;
|
|
2411
|
+
MapPrototype.withMutations = withMutations;
|
|
2412
|
+
MapPrototype.wasAltered = wasAltered;
|
|
2413
|
+
MapPrototype.asImmutable = asImmutable;
|
|
2414
|
+
MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
|
|
2149
2415
|
MapPrototype['@@transducer/step'] = function(result, arr) {
|
|
2150
2416
|
return result.set(arr[0], arr[1]);
|
|
2151
2417
|
};
|
|
@@ -2170,7 +2436,7 @@ ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
|
|
|
2170
2436
|
return notSetValue;
|
|
2171
2437
|
};
|
|
2172
2438
|
|
|
2173
|
-
ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2439
|
+
ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2174
2440
|
var removed = value === NOT_SET;
|
|
2175
2441
|
|
|
2176
2442
|
var entries = this.entries;
|
|
@@ -2243,7 +2509,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue
|
|
|
2243
2509
|
);
|
|
2244
2510
|
};
|
|
2245
2511
|
|
|
2246
|
-
BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2512
|
+
BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2247
2513
|
if (keyHash === undefined) {
|
|
2248
2514
|
keyHash = hash(key);
|
|
2249
2515
|
}
|
|
@@ -2295,7 +2561,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k
|
|
|
2295
2561
|
var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
|
|
2296
2562
|
var newNodes = exists
|
|
2297
2563
|
? newNode
|
|
2298
|
-
?
|
|
2564
|
+
? setAt(nodes, idx, newNode, isEditable)
|
|
2299
2565
|
: spliceOut(nodes, idx, isEditable)
|
|
2300
2566
|
: spliceIn(nodes, idx, newNode, isEditable);
|
|
2301
2567
|
|
|
@@ -2325,7 +2591,7 @@ HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue)
|
|
|
2325
2591
|
: notSetValue;
|
|
2326
2592
|
};
|
|
2327
2593
|
|
|
2328
|
-
HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2594
|
+
HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2329
2595
|
if (keyHash === undefined) {
|
|
2330
2596
|
keyHash = hash(key);
|
|
2331
2597
|
}
|
|
@@ -2363,7 +2629,7 @@ HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, ke
|
|
|
2363
2629
|
}
|
|
2364
2630
|
|
|
2365
2631
|
var isEditable = ownerID && ownerID === this.ownerID;
|
|
2366
|
-
var newNodes =
|
|
2632
|
+
var newNodes = setAt(nodes, idx, newNode, isEditable);
|
|
2367
2633
|
|
|
2368
2634
|
if (isEditable) {
|
|
2369
2635
|
this.count = newCount;
|
|
@@ -2390,7 +2656,7 @@ HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue
|
|
|
2390
2656
|
return notSetValue;
|
|
2391
2657
|
};
|
|
2392
2658
|
|
|
2393
|
-
HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2659
|
+
HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2394
2660
|
if (keyHash === undefined) {
|
|
2395
2661
|
keyHash = hash(key);
|
|
2396
2662
|
}
|
|
@@ -2460,7 +2726,7 @@ ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
|
|
|
2460
2726
|
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
|
|
2461
2727
|
};
|
|
2462
2728
|
|
|
2463
|
-
ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2729
|
+
ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
|
|
2464
2730
|
var removed = value === NOT_SET;
|
|
2465
2731
|
var keyMatch = is(key, this.entry[0]);
|
|
2466
2732
|
if (keyMatch ? value === this.entry[1] : removed) {
|
|
@@ -2724,90 +2990,6 @@ function expandNodes(ownerID, nodes, bitmap, including, node) {
|
|
|
2724
2990
|
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
|
|
2725
2991
|
}
|
|
2726
2992
|
|
|
2727
|
-
function mergeIntoMapWith(map, merger, collections) {
|
|
2728
|
-
var iters = [];
|
|
2729
|
-
for (var ii = 0; ii < collections.length; ii++) {
|
|
2730
|
-
iters.push(KeyedCollection(collections[ii]));
|
|
2731
|
-
}
|
|
2732
|
-
return mergeIntoCollectionWith(map, merger, iters);
|
|
2733
|
-
}
|
|
2734
|
-
|
|
2735
|
-
function alwaysNewVal(oldVal, newVal) {
|
|
2736
|
-
return newVal;
|
|
2737
|
-
}
|
|
2738
|
-
|
|
2739
|
-
function deepMergerWith(merger) {
|
|
2740
|
-
return function(oldVal, newVal, key) {
|
|
2741
|
-
if (oldVal && newVal && typeof newVal === 'object') {
|
|
2742
|
-
if (oldVal.mergeDeepWith) {
|
|
2743
|
-
return oldVal.mergeDeepWith(merger, newVal);
|
|
2744
|
-
}
|
|
2745
|
-
if (oldVal.merge) {
|
|
2746
|
-
return oldVal.merge(newVal);
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
var nextValue = merger(oldVal, newVal, key);
|
|
2750
|
-
return is(oldVal, nextValue) ? oldVal : nextValue;
|
|
2751
|
-
};
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2754
|
-
function mergeIntoCollectionWith(collection, merger, iters) {
|
|
2755
|
-
iters = iters.filter(function (x) { return x.size !== 0; });
|
|
2756
|
-
if (iters.length === 0) {
|
|
2757
|
-
return collection;
|
|
2758
|
-
}
|
|
2759
|
-
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
|
|
2760
|
-
return collection.constructor(iters[0]);
|
|
2761
|
-
}
|
|
2762
|
-
return collection.withMutations(function (collection) {
|
|
2763
|
-
var mergeIntoCollection = merger
|
|
2764
|
-
? function (value, key) {
|
|
2765
|
-
collection.update(
|
|
2766
|
-
key,
|
|
2767
|
-
NOT_SET,
|
|
2768
|
-
function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
|
|
2769
|
-
);
|
|
2770
|
-
}
|
|
2771
|
-
: function (value, key) {
|
|
2772
|
-
collection.set(key, value);
|
|
2773
|
-
};
|
|
2774
|
-
for (var ii = 0; ii < iters.length; ii++) {
|
|
2775
|
-
iters[ii].forEach(mergeIntoCollection);
|
|
2776
|
-
}
|
|
2777
|
-
});
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
function updateInDeepMap(existing, keyPath, i, notSetValue, updater) {
|
|
2781
|
-
var isNotSet = existing === NOT_SET;
|
|
2782
|
-
if (i === keyPath.length) {
|
|
2783
|
-
var existingValue = isNotSet ? notSetValue : existing;
|
|
2784
|
-
var newValue = updater(existingValue);
|
|
2785
|
-
return newValue === existingValue ? existing : newValue;
|
|
2786
|
-
}
|
|
2787
|
-
if (!(isNotSet || (existing && existing.set))) {
|
|
2788
|
-
throw new TypeError(
|
|
2789
|
-
'Invalid keyPath: Value at [' +
|
|
2790
|
-
keyPath.slice(0, i).map(quoteString) +
|
|
2791
|
-
'] does not have a .set() method and cannot be updated: ' +
|
|
2792
|
-
existing
|
|
2793
|
-
);
|
|
2794
|
-
}
|
|
2795
|
-
var key = keyPath[i];
|
|
2796
|
-
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
|
|
2797
|
-
var nextUpdated = updateInDeepMap(
|
|
2798
|
-
nextExisting,
|
|
2799
|
-
keyPath,
|
|
2800
|
-
i + 1,
|
|
2801
|
-
notSetValue,
|
|
2802
|
-
updater
|
|
2803
|
-
);
|
|
2804
|
-
return nextUpdated === nextExisting
|
|
2805
|
-
? existing
|
|
2806
|
-
: nextUpdated === NOT_SET
|
|
2807
|
-
? existing.remove(key)
|
|
2808
|
-
: (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
|
|
2809
|
-
}
|
|
2810
|
-
|
|
2811
2993
|
function popCount(x) {
|
|
2812
2994
|
x -= (x >> 1) & 0x55555555;
|
|
2813
2995
|
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
|
@@ -2817,7 +2999,7 @@ function popCount(x) {
|
|
|
2817
2999
|
return x & 0x7f;
|
|
2818
3000
|
}
|
|
2819
3001
|
|
|
2820
|
-
function
|
|
3002
|
+
function setAt(array, idx, val, canEdit) {
|
|
2821
3003
|
var newArray = canEdit ? array : arrCopy(array);
|
|
2822
3004
|
newArray[idx] = val;
|
|
2823
3005
|
return newArray;
|
|
@@ -2975,8 +3157,30 @@ var List = (function (IndexedCollection$$1) {
|
|
|
2975
3157
|
|
|
2976
3158
|
// @pragma Composition
|
|
2977
3159
|
|
|
2978
|
-
List.prototype.
|
|
2979
|
-
|
|
3160
|
+
List.prototype.concat = function concat (/*...collections*/) {
|
|
3161
|
+
var arguments$1 = arguments;
|
|
3162
|
+
|
|
3163
|
+
var seqs = [];
|
|
3164
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
3165
|
+
var argument = arguments$1[i];
|
|
3166
|
+
var seq = IndexedCollection$$1(
|
|
3167
|
+
typeof argument !== 'string' && hasIterator(argument)
|
|
3168
|
+
? argument
|
|
3169
|
+
: [argument]
|
|
3170
|
+
);
|
|
3171
|
+
if (seq.size !== 0) {
|
|
3172
|
+
seqs.push(seq);
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
if (seqs.length === 0) {
|
|
3176
|
+
return this;
|
|
3177
|
+
}
|
|
3178
|
+
if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
|
|
3179
|
+
return this.constructor(seqs[0]);
|
|
3180
|
+
}
|
|
3181
|
+
return this.withMutations(function (list) {
|
|
3182
|
+
seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
|
|
3183
|
+
});
|
|
2980
3184
|
};
|
|
2981
3185
|
|
|
2982
3186
|
List.prototype.setSize = function setSize (size) {
|
|
@@ -3059,21 +3263,23 @@ var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
|
3059
3263
|
var ListPrototype = List.prototype;
|
|
3060
3264
|
ListPrototype[IS_LIST_SENTINEL] = true;
|
|
3061
3265
|
ListPrototype[DELETE] = ListPrototype.remove;
|
|
3062
|
-
ListPrototype.
|
|
3063
|
-
ListPrototype.
|
|
3064
|
-
ListPrototype.
|
|
3065
|
-
ListPrototype.
|
|
3066
|
-
ListPrototype.
|
|
3067
|
-
ListPrototype.
|
|
3068
|
-
ListPrototype.
|
|
3069
|
-
ListPrototype.
|
|
3070
|
-
ListPrototype.
|
|
3071
|
-
ListPrototype.
|
|
3072
|
-
ListPrototype['@@transducer/init'] = ListPrototype.asMutable;
|
|
3266
|
+
ListPrototype.merge = ListPrototype.concat;
|
|
3267
|
+
ListPrototype.setIn = setIn$$1;
|
|
3268
|
+
ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
|
|
3269
|
+
ListPrototype.update = update$$1;
|
|
3270
|
+
ListPrototype.updateIn = updateIn$1;
|
|
3271
|
+
ListPrototype.mergeIn = mergeIn;
|
|
3272
|
+
ListPrototype.mergeDeepIn = mergeDeepIn;
|
|
3273
|
+
ListPrototype.withMutations = withMutations;
|
|
3274
|
+
ListPrototype.wasAltered = wasAltered;
|
|
3275
|
+
ListPrototype.asImmutable = asImmutable;
|
|
3276
|
+
ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
|
|
3073
3277
|
ListPrototype['@@transducer/step'] = function(result, arr) {
|
|
3074
3278
|
return result.push(arr);
|
|
3075
3279
|
};
|
|
3076
|
-
ListPrototype['@@transducer/result'] =
|
|
3280
|
+
ListPrototype['@@transducer/result'] = function(obj) {
|
|
3281
|
+
return obj.asImmutable();
|
|
3282
|
+
};
|
|
3077
3283
|
|
|
3078
3284
|
var VNode = function VNode(array, ownerID) {
|
|
3079
3285
|
this.array = array;
|
|
@@ -3846,18 +4052,19 @@ var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
|
3846
4052
|
|
|
3847
4053
|
var StackPrototype = Stack.prototype;
|
|
3848
4054
|
StackPrototype[IS_STACK_SENTINEL] = true;
|
|
3849
|
-
StackPrototype.withMutations = MapPrototype.withMutations;
|
|
3850
|
-
StackPrototype.asMutable = MapPrototype.asMutable;
|
|
3851
|
-
StackPrototype.asImmutable = MapPrototype.asImmutable;
|
|
3852
|
-
StackPrototype.wasAltered = MapPrototype.wasAltered;
|
|
3853
4055
|
StackPrototype.shift = StackPrototype.pop;
|
|
3854
4056
|
StackPrototype.unshift = StackPrototype.push;
|
|
3855
4057
|
StackPrototype.unshiftAll = StackPrototype.pushAll;
|
|
3856
|
-
StackPrototype
|
|
4058
|
+
StackPrototype.withMutations = withMutations;
|
|
4059
|
+
StackPrototype.wasAltered = wasAltered;
|
|
4060
|
+
StackPrototype.asImmutable = asImmutable;
|
|
4061
|
+
StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
|
|
3857
4062
|
StackPrototype['@@transducer/step'] = function(result, arr) {
|
|
3858
4063
|
return result.unshift(arr);
|
|
3859
4064
|
};
|
|
3860
|
-
StackPrototype['@@transducer/result'] =
|
|
4065
|
+
StackPrototype['@@transducer/result'] = function(obj) {
|
|
4066
|
+
return obj.asImmutable();
|
|
4067
|
+
};
|
|
3861
4068
|
|
|
3862
4069
|
function makeStack(size, head, ownerID, hash) {
|
|
3863
4070
|
var map = Object.create(StackPrototype);
|
|
@@ -3951,6 +4158,14 @@ function mixin(ctor, methods) {
|
|
|
3951
4158
|
return ctor;
|
|
3952
4159
|
}
|
|
3953
4160
|
|
|
4161
|
+
function toJS(value) {
|
|
4162
|
+
return isDataStructure(value)
|
|
4163
|
+
? Seq(value)
|
|
4164
|
+
.map(toJS)
|
|
4165
|
+
.toJSON()
|
|
4166
|
+
: value;
|
|
4167
|
+
}
|
|
4168
|
+
|
|
3954
4169
|
var Set = (function (SetCollection$$1) {
|
|
3955
4170
|
function Set(value) {
|
|
3956
4171
|
return value === null || value === undefined
|
|
@@ -4130,15 +4345,16 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
|
4130
4345
|
var SetPrototype = Set.prototype;
|
|
4131
4346
|
SetPrototype[IS_SET_SENTINEL] = true;
|
|
4132
4347
|
SetPrototype[DELETE] = SetPrototype.remove;
|
|
4133
|
-
SetPrototype.merge = SetPrototype.union;
|
|
4134
|
-
SetPrototype.withMutations =
|
|
4135
|
-
SetPrototype.
|
|
4136
|
-
SetPrototype.
|
|
4137
|
-
SetPrototype['@@transducer/init'] = SetPrototype.asMutable;
|
|
4348
|
+
SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
|
|
4349
|
+
SetPrototype.withMutations = withMutations;
|
|
4350
|
+
SetPrototype.asImmutable = asImmutable;
|
|
4351
|
+
SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
|
|
4138
4352
|
SetPrototype['@@transducer/step'] = function(result, arr) {
|
|
4139
4353
|
return result.add(arr);
|
|
4140
4354
|
};
|
|
4141
|
-
SetPrototype['@@transducer/result'] =
|
|
4355
|
+
SetPrototype['@@transducer/result'] = function(obj) {
|
|
4356
|
+
return obj.asImmutable();
|
|
4357
|
+
};
|
|
4142
4358
|
|
|
4143
4359
|
SetPrototype.__empty = emptySet;
|
|
4144
4360
|
SetPrototype.__make = makeSet;
|
|
@@ -4306,6 +4522,39 @@ var Range = (function (IndexedSeq$$1) {
|
|
|
4306
4522
|
|
|
4307
4523
|
var EMPTY_RANGE;
|
|
4308
4524
|
|
|
4525
|
+
function getIn$1(collection, searchKeyPath, notSetValue) {
|
|
4526
|
+
var keyPath = coerceKeyPath(searchKeyPath);
|
|
4527
|
+
var i = 0;
|
|
4528
|
+
while (i !== keyPath.length) {
|
|
4529
|
+
collection = get(collection, keyPath[i++], NOT_SET);
|
|
4530
|
+
if (collection === NOT_SET) {
|
|
4531
|
+
return notSetValue;
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
return collection;
|
|
4535
|
+
}
|
|
4536
|
+
|
|
4537
|
+
function getIn$$1(searchKeyPath, notSetValue) {
|
|
4538
|
+
return getIn$1(this, searchKeyPath, notSetValue);
|
|
4539
|
+
}
|
|
4540
|
+
|
|
4541
|
+
function hasIn$1(collection, keyPath) {
|
|
4542
|
+
return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4545
|
+
function hasIn$$1(searchKeyPath) {
|
|
4546
|
+
return hasIn$1(this, searchKeyPath);
|
|
4547
|
+
}
|
|
4548
|
+
|
|
4549
|
+
function toObject() {
|
|
4550
|
+
assertNotInfinite(this.size);
|
|
4551
|
+
var object = {};
|
|
4552
|
+
this.__iterate(function (v, k) {
|
|
4553
|
+
object[k] = v;
|
|
4554
|
+
});
|
|
4555
|
+
return object;
|
|
4556
|
+
}
|
|
4557
|
+
|
|
4309
4558
|
// Note: all of these methods are deprecated.
|
|
4310
4559
|
Collection.isIterable = isCollection;
|
|
4311
4560
|
Collection.isKeyed = isKeyed;
|
|
@@ -4335,9 +4584,7 @@ mixin(Collection, {
|
|
|
4335
4584
|
},
|
|
4336
4585
|
|
|
4337
4586
|
toJS: function toJS$1() {
|
|
4338
|
-
return this
|
|
4339
|
-
.map(toJS)
|
|
4340
|
-
.toJSON();
|
|
4587
|
+
return toJS(this);
|
|
4341
4588
|
},
|
|
4342
4589
|
|
|
4343
4590
|
toKeyedSeq: function toKeyedSeq() {
|
|
@@ -4349,14 +4596,7 @@ mixin(Collection, {
|
|
|
4349
4596
|
return Map(this.toKeyedSeq());
|
|
4350
4597
|
},
|
|
4351
4598
|
|
|
4352
|
-
toObject:
|
|
4353
|
-
assertNotInfinite(this.size);
|
|
4354
|
-
var object = {};
|
|
4355
|
-
this.__iterate(function (v, k) {
|
|
4356
|
-
object[k] = v;
|
|
4357
|
-
});
|
|
4358
|
-
return object;
|
|
4359
|
-
},
|
|
4599
|
+
toObject: toObject,
|
|
4360
4600
|
|
|
4361
4601
|
toOrderedMap: function toOrderedMap() {
|
|
4362
4602
|
// Use Late Binding here to solve the circular dependency.
|
|
@@ -4554,13 +4794,6 @@ mixin(Collection, {
|
|
|
4554
4794
|
.map(entryMapper)
|
|
4555
4795
|
.toIndexedSeq();
|
|
4556
4796
|
entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
|
|
4557
|
-
|
|
4558
|
-
// Entries are plain Array, which do not define toJS, so it must
|
|
4559
|
-
// manually converts keys and values before conversion.
|
|
4560
|
-
entriesSequence.toJS = function() {
|
|
4561
|
-
return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON();
|
|
4562
|
-
};
|
|
4563
|
-
|
|
4564
4797
|
return entriesSequence;
|
|
4565
4798
|
},
|
|
4566
4799
|
|
|
@@ -4622,9 +4855,7 @@ mixin(Collection, {
|
|
|
4622
4855
|
return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
|
|
4623
4856
|
},
|
|
4624
4857
|
|
|
4625
|
-
getIn:
|
|
4626
|
-
return getIn(this, notSetValue, searchKeyPath, true /* report bad path */);
|
|
4627
|
-
},
|
|
4858
|
+
getIn: getIn$$1,
|
|
4628
4859
|
|
|
4629
4860
|
groupBy: function groupBy(grouper, context) {
|
|
4630
4861
|
return groupByFactory(this, grouper, context);
|
|
@@ -4634,12 +4865,7 @@ mixin(Collection, {
|
|
|
4634
4865
|
return this.get(searchKey, NOT_SET) !== NOT_SET;
|
|
4635
4866
|
},
|
|
4636
4867
|
|
|
4637
|
-
hasIn:
|
|
4638
|
-
return (
|
|
4639
|
-
getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !==
|
|
4640
|
-
NOT_SET
|
|
4641
|
-
);
|
|
4642
|
-
},
|
|
4868
|
+
hasIn: hasIn$$1,
|
|
4643
4869
|
|
|
4644
4870
|
isSubset: function isSubset(iter) {
|
|
4645
4871
|
iter = typeof iter.includes === 'function' ? iter : Collection(iter);
|
|
@@ -4803,7 +5029,7 @@ mixin(KeyedCollection, {
|
|
|
4803
5029
|
var KeyedCollectionPrototype = KeyedCollection.prototype;
|
|
4804
5030
|
KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true;
|
|
4805
5031
|
KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
|
|
4806
|
-
KeyedCollectionPrototype.toJSON =
|
|
5032
|
+
KeyedCollectionPrototype.toJSON = toObject;
|
|
4807
5033
|
KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
|
|
4808
5034
|
|
|
4809
5035
|
mixin(IndexedCollection, {
|
|
@@ -4991,10 +5217,6 @@ function entryMapper(v, k) {
|
|
|
4991
5217
|
return [k, v];
|
|
4992
5218
|
}
|
|
4993
5219
|
|
|
4994
|
-
function toJS(value) {
|
|
4995
|
-
return value && typeof value.toJS === 'function' ? value.toJS() : value;
|
|
4996
|
-
}
|
|
4997
|
-
|
|
4998
5220
|
function not(predicate) {
|
|
4999
5221
|
return function() {
|
|
5000
5222
|
return !predicate.apply(this, arguments);
|
|
@@ -5057,40 +5279,6 @@ function hashMerge(a, b) {
|
|
|
5057
5279
|
return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
|
|
5058
5280
|
}
|
|
5059
5281
|
|
|
5060
|
-
function warn(message) {
|
|
5061
|
-
/* eslint-disable no-console */
|
|
5062
|
-
if (typeof console === 'object' && console.warn) {
|
|
5063
|
-
console.warn(message);
|
|
5064
|
-
} else {
|
|
5065
|
-
throw new Error(message);
|
|
5066
|
-
}
|
|
5067
|
-
/* eslint-enable no-console */
|
|
5068
|
-
}
|
|
5069
|
-
|
|
5070
|
-
function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) {
|
|
5071
|
-
var keyPath = coerceKeyPath(searchKeyPath);
|
|
5072
|
-
var i = 0;
|
|
5073
|
-
while (i !== keyPath.length) {
|
|
5074
|
-
if (!value || !value.get) {
|
|
5075
|
-
if (reportBadKeyPath) {
|
|
5076
|
-
warn(
|
|
5077
|
-
'Invalid keyPath: Value at [' +
|
|
5078
|
-
keyPath.slice(0, i).map(quoteString) +
|
|
5079
|
-
'] does not have a .get() method: ' +
|
|
5080
|
-
value +
|
|
5081
|
-
'\nThis warning will throw in a future version'
|
|
5082
|
-
);
|
|
5083
|
-
}
|
|
5084
|
-
return notSetValue;
|
|
5085
|
-
}
|
|
5086
|
-
value = value.get(keyPath[i++], NOT_SET);
|
|
5087
|
-
if (value === NOT_SET) {
|
|
5088
|
-
return notSetValue;
|
|
5089
|
-
}
|
|
5090
|
-
}
|
|
5091
|
-
return value;
|
|
5092
|
-
}
|
|
5093
|
-
|
|
5094
5282
|
var OrderedSet = (function (Set$$1) {
|
|
5095
5283
|
function OrderedSet(value) {
|
|
5096
5284
|
return value === null || value === undefined
|
|
@@ -5281,8 +5469,12 @@ Record.prototype.toSeq = function toSeq () {
|
|
|
5281
5469
|
return recordSeq(this);
|
|
5282
5470
|
};
|
|
5283
5471
|
|
|
5284
|
-
Record.prototype.toJS = function toJS () {
|
|
5285
|
-
return
|
|
5472
|
+
Record.prototype.toJS = function toJS$1 () {
|
|
5473
|
+
return toJS(this);
|
|
5474
|
+
};
|
|
5475
|
+
|
|
5476
|
+
Record.prototype.entries = function entries () {
|
|
5477
|
+
return this.__iterator(ITERATE_ENTRIES);
|
|
5286
5478
|
};
|
|
5287
5479
|
|
|
5288
5480
|
Record.prototype.__iterator = function __iterator (type, reverse) {
|
|
@@ -5311,26 +5503,27 @@ Record.getDescriptiveName = recordName;
|
|
|
5311
5503
|
var RecordPrototype = Record.prototype;
|
|
5312
5504
|
RecordPrototype[IS_RECORD_SENTINEL] = true;
|
|
5313
5505
|
RecordPrototype[DELETE] = RecordPrototype.remove;
|
|
5314
|
-
RecordPrototype.deleteIn = RecordPrototype.removeIn =
|
|
5315
|
-
RecordPrototype.getIn =
|
|
5506
|
+
RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
|
|
5507
|
+
RecordPrototype.getIn = getIn$$1;
|
|
5316
5508
|
RecordPrototype.hasIn = CollectionPrototype.hasIn;
|
|
5317
|
-
RecordPrototype.merge =
|
|
5318
|
-
RecordPrototype.mergeWith =
|
|
5319
|
-
RecordPrototype.mergeIn =
|
|
5320
|
-
RecordPrototype.mergeDeep =
|
|
5321
|
-
RecordPrototype.mergeDeepWith =
|
|
5322
|
-
RecordPrototype.mergeDeepIn =
|
|
5323
|
-
RecordPrototype.setIn =
|
|
5324
|
-
RecordPrototype.update =
|
|
5325
|
-
RecordPrototype.updateIn =
|
|
5326
|
-
RecordPrototype.withMutations =
|
|
5327
|
-
RecordPrototype.asMutable =
|
|
5328
|
-
RecordPrototype.asImmutable =
|
|
5329
|
-
RecordPrototype[ITERATOR_SYMBOL] =
|
|
5509
|
+
RecordPrototype.merge = merge;
|
|
5510
|
+
RecordPrototype.mergeWith = mergeWith;
|
|
5511
|
+
RecordPrototype.mergeIn = mergeIn;
|
|
5512
|
+
RecordPrototype.mergeDeep = mergeDeep;
|
|
5513
|
+
RecordPrototype.mergeDeepWith = mergeDeepWith;
|
|
5514
|
+
RecordPrototype.mergeDeepIn = mergeDeepIn;
|
|
5515
|
+
RecordPrototype.setIn = setIn$$1;
|
|
5516
|
+
RecordPrototype.update = update$$1;
|
|
5517
|
+
RecordPrototype.updateIn = updateIn$1;
|
|
5518
|
+
RecordPrototype.withMutations = withMutations;
|
|
5519
|
+
RecordPrototype.asMutable = asMutable;
|
|
5520
|
+
RecordPrototype.asImmutable = asImmutable;
|
|
5521
|
+
RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
|
|
5330
5522
|
RecordPrototype.toJSON = RecordPrototype.toObject =
|
|
5331
5523
|
CollectionPrototype.toObject;
|
|
5332
|
-
RecordPrototype.inspect = RecordPrototype.toSource =
|
|
5333
|
-
|
|
5524
|
+
RecordPrototype.inspect = RecordPrototype.toSource = function() {
|
|
5525
|
+
return this.toString();
|
|
5526
|
+
};
|
|
5334
5527
|
|
|
5335
5528
|
function makeRecord(likeRecord, values, ownerID) {
|
|
5336
5529
|
var record = Object.create(Object.getPrototypeOf(likeRecord));
|
|
@@ -5504,14 +5697,9 @@ function defaultConverter(k, v) {
|
|
|
5504
5697
|
return isKeyed(v) ? v.toMap() : v.toList();
|
|
5505
5698
|
}
|
|
5506
5699
|
|
|
5507
|
-
|
|
5508
|
-
return (
|
|
5509
|
-
value && (value.constructor === Object || value.constructor === undefined)
|
|
5510
|
-
);
|
|
5511
|
-
}
|
|
5512
|
-
|
|
5513
|
-
var version = "4.0.0-rc.5";
|
|
5700
|
+
var version = "4.0.0-rc.9";
|
|
5514
5701
|
|
|
5702
|
+
// Functional read/write API
|
|
5515
5703
|
var Immutable = {
|
|
5516
5704
|
version: version,
|
|
5517
5705
|
|
|
@@ -5541,11 +5729,26 @@ var Immutable = {
|
|
|
5541
5729
|
isIndexed: isIndexed,
|
|
5542
5730
|
isAssociative: isAssociative,
|
|
5543
5731
|
isOrdered: isOrdered,
|
|
5544
|
-
isValueObject: isValueObject
|
|
5732
|
+
isValueObject: isValueObject,
|
|
5733
|
+
|
|
5734
|
+
get: get,
|
|
5735
|
+
getIn: getIn$1,
|
|
5736
|
+
has: has,
|
|
5737
|
+
hasIn: hasIn$1,
|
|
5738
|
+
merge: merge$1,
|
|
5739
|
+
mergeDeep: mergeDeep$1,
|
|
5740
|
+
mergeWith: mergeWith$1,
|
|
5741
|
+
mergeDeepWith: mergeDeepWith$1,
|
|
5742
|
+
remove: remove,
|
|
5743
|
+
removeIn: removeIn,
|
|
5744
|
+
set: set,
|
|
5745
|
+
setIn: setIn$1,
|
|
5746
|
+
update: update$1,
|
|
5747
|
+
updateIn: updateIn
|
|
5545
5748
|
};
|
|
5546
5749
|
|
|
5547
5750
|
// Note: Iterable is deprecated
|
|
5548
5751
|
var Iterable = Collection;
|
|
5549
5752
|
|
|
5550
|
-
export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };
|
|
5753
|
+
export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn$1 as getIn, has, hasIn$1 as hasIn, merge$1 as merge, mergeDeep$1 as mergeDeep, mergeWith$1 as mergeWith, mergeDeepWith$1 as mergeDeepWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn };
|
|
5551
5754
|
export default Immutable;
|