immutable 5.0.0-beta.3 → 5.0.0-beta.5

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.
Files changed (82) hide show
  1. package/README.md +4 -4
  2. package/dist/es/Collection.js +75 -0
  3. package/dist/es/CollectionImpl.js +781 -0
  4. package/dist/es/Hash.js +260 -0
  5. package/dist/es/Immutable.js +73 -0
  6. package/dist/es/Iterator.js +106 -0
  7. package/dist/es/List.js +692 -0
  8. package/dist/es/Map.js +833 -0
  9. package/dist/es/Math.js +45 -0
  10. package/dist/es/Operations.js +953 -0
  11. package/dist/es/OrderedMap.js +195 -0
  12. package/dist/es/OrderedSet.js +91 -0
  13. package/dist/es/PairSorting.js +30 -0
  14. package/dist/es/Range.js +175 -0
  15. package/dist/es/Record.js +291 -0
  16. package/dist/es/Repeat.js +130 -0
  17. package/dist/es/Seq.js +397 -0
  18. package/dist/es/Set.js +278 -0
  19. package/dist/es/Stack.js +260 -0
  20. package/dist/es/TrieUtils.js +117 -0
  21. package/dist/es/fromJS.js +74 -0
  22. package/dist/es/functional/get.js +38 -0
  23. package/dist/es/functional/getIn.js +41 -0
  24. package/dist/es/functional/has.js +35 -0
  25. package/dist/es/functional/hasIn.js +32 -0
  26. package/dist/es/functional/merge.js +137 -0
  27. package/dist/es/functional/remove.js +56 -0
  28. package/dist/es/functional/removeIn.js +32 -0
  29. package/dist/es/functional/set.js +52 -0
  30. package/dist/es/functional/setIn.js +32 -0
  31. package/dist/es/functional/update.js +31 -0
  32. package/dist/es/functional/updateIn.js +94 -0
  33. package/dist/es/is.js +108 -0
  34. package/dist/es/methods/asImmutable.js +29 -0
  35. package/dist/es/methods/asMutable.js +31 -0
  36. package/dist/es/methods/deleteIn.js +31 -0
  37. package/dist/es/methods/getIn.js +31 -0
  38. package/dist/es/methods/hasIn.js +31 -0
  39. package/dist/es/methods/merge.js +79 -0
  40. package/dist/es/methods/mergeDeep.js +41 -0
  41. package/dist/es/methods/mergeDeepIn.js +37 -0
  42. package/dist/es/methods/mergeIn.js +36 -0
  43. package/dist/es/methods/setIn.js +31 -0
  44. package/dist/es/methods/toObject.js +36 -0
  45. package/dist/es/methods/update.js +33 -0
  46. package/dist/es/methods/updateIn.js +31 -0
  47. package/dist/es/methods/wasAltered.js +29 -0
  48. package/dist/es/methods/withMutations.js +31 -0
  49. package/dist/es/package.json.js +27 -0
  50. package/dist/es/predicates/isAssociative.js +32 -0
  51. package/dist/es/predicates/isCollection.js +32 -0
  52. package/dist/es/predicates/isImmutable.js +32 -0
  53. package/dist/es/predicates/isIndexed.js +31 -0
  54. package/dist/es/predicates/isKeyed.js +31 -0
  55. package/dist/es/predicates/isList.js +31 -0
  56. package/dist/es/predicates/isMap.js +31 -0
  57. package/dist/es/predicates/isOrdered.js +31 -0
  58. package/dist/es/predicates/isOrderedMap.js +32 -0
  59. package/dist/es/predicates/isOrderedSet.js +32 -0
  60. package/dist/es/predicates/isRecord.js +31 -0
  61. package/dist/es/predicates/isSeq.js +31 -0
  62. package/dist/es/predicates/isSet.js +31 -0
  63. package/dist/es/predicates/isStack.js +31 -0
  64. package/dist/es/predicates/isValueObject.js +33 -0
  65. package/dist/es/toJS.js +54 -0
  66. package/dist/es/utils/arrCopy.js +36 -0
  67. package/dist/es/utils/assertNotInfinite.js +34 -0
  68. package/dist/es/utils/coerceKeyPath.js +40 -0
  69. package/dist/es/utils/deepEqual.js +99 -0
  70. package/dist/es/utils/hasOwnProperty.js +27 -0
  71. package/dist/es/utils/invariant.js +29 -0
  72. package/dist/es/utils/isArrayLike.js +44 -0
  73. package/dist/es/utils/isDataStructure.js +39 -0
  74. package/dist/es/utils/isPlainObj.js +52 -0
  75. package/dist/es/utils/mixin.js +38 -0
  76. package/dist/es/utils/quoteString.js +36 -0
  77. package/dist/es/utils/shallowCopy.js +41 -0
  78. package/dist/immutable.d.ts +137 -16
  79. package/dist/immutable.js +25 -68
  80. package/dist/immutable.min.js +2 -32
  81. package/package.json +2 -3
  82. package/dist/immutable.es.js +0 -5965
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import { isImmutable } from '../predicates/isImmutable.js';
26
+ import isPlainObject from './isPlainObj.js';
27
+
28
+ /**
29
+ * Returns true if the value is a potentially-persistent data structure, either
30
+ * provided by Immutable.js or a plain Array or Object.
31
+ */
32
+ function isDataStructure(value) {
33
+ return (
34
+ typeof value === 'object' &&
35
+ (isImmutable(value) || Array.isArray(value) || isPlainObject(value))
36
+ );
37
+ }
38
+
39
+ export { isDataStructure as default };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ var toString = Object.prototype.toString;
26
+
27
+ function isPlainObject(value) {
28
+ // The base prototype's toString deals with Argument objects and native namespaces like Math
29
+ if (
30
+ !value ||
31
+ typeof value !== 'object' ||
32
+ toString.call(value) !== '[object Object]'
33
+ ) {
34
+ return false;
35
+ }
36
+
37
+ var proto = Object.getPrototypeOf(value);
38
+ if (proto === null) {
39
+ return true;
40
+ }
41
+
42
+ // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
43
+ var parentProto = proto;
44
+ var nextProto = Object.getPrototypeOf(proto);
45
+ while (nextProto !== null) {
46
+ parentProto = nextProto;
47
+ nextProto = Object.getPrototypeOf(parentProto);
48
+ }
49
+ return parentProto === proto;
50
+ }
51
+
52
+ export { isPlainObject as default };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Contributes additional methods to a constructor
27
+ */
28
+ function mixin(ctor, methods) {
29
+ var keyCopier = function (key) {
30
+ ctor.prototype[key] = methods[key];
31
+ };
32
+ Object.keys(methods).forEach(keyCopier);
33
+ Object.getOwnPropertySymbols &&
34
+ Object.getOwnPropertySymbols(methods).forEach(keyCopier);
35
+ return ctor;
36
+ }
37
+
38
+ export { mixin as default };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ /**
26
+ * Converts a value to a string, adding quotes if a string was provided.
27
+ */
28
+ function quoteString(value) {
29
+ try {
30
+ return typeof value === 'string' ? JSON.stringify(value) : String(value);
31
+ } catch (_ignoreError) {
32
+ return JSON.stringify(value);
33
+ }
34
+ }
35
+
36
+ export { quoteString as default };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import arrCopy from './arrCopy.js';
26
+ import hasOwnProperty from './hasOwnProperty.js';
27
+
28
+ function shallowCopy(from) {
29
+ if (Array.isArray(from)) {
30
+ return arrCopy(from);
31
+ }
32
+ var to = {};
33
+ for (var key in from) {
34
+ if (hasOwnProperty.call(from, key)) {
35
+ to[key] = from[key];
36
+ }
37
+ }
38
+ return to;
39
+ }
40
+
41
+ export { shallowCopy as default };
@@ -112,6 +112,11 @@ declare namespace Immutable {
112
112
  {
113
113
  [key in keyof R]: ContainObject<R[key]> extends true ? unknown : R[key];
114
114
  }
115
+ : T extends MapOf<infer R>
116
+ ? // convert MapOf to DeepCopy plain JS object
117
+ {
118
+ [key in keyof R]: ContainObject<R[key]> extends true ? unknown : R[key];
119
+ }
115
120
  : T extends Collection.Keyed<infer KeyedKey, infer V>
116
121
  ? // convert KeyedCollection to DeepCopy plain JS object
117
122
  {
@@ -841,9 +846,96 @@ declare namespace Immutable {
841
846
  * not altered.
842
847
  */
843
848
  function Map<K, V>(collection?: Iterable<[K, V]>): Map<K, V>;
849
+ function Map<R extends { [key in string | number | symbol]: unknown }>(
850
+ obj: R
851
+ ): MapOf<R>;
844
852
  function Map<V>(obj: { [key: string]: V }): Map<string, V>;
845
853
  function Map<K extends string | symbol, V>(obj: { [P in K]?: V }): Map<K, V>;
846
854
 
855
+ /**
856
+ * Represent a Map constructed by an object
857
+ *
858
+ * @ignore
859
+ */
860
+ interface MapOf<R extends { [key in string | number | symbol]: unknown }>
861
+ extends Map<keyof R, R[keyof R]> {
862
+ /**
863
+ * Returns the value associated with the provided key, or notSetValue if
864
+ * the Collection does not contain this key.
865
+ *
866
+ * Note: it is possible a key may be associated with an `undefined` value,
867
+ * so if `notSetValue` is not provided and this method returns `undefined`,
868
+ * that does not guarantee the key was not found.
869
+ */
870
+ get<K extends keyof R>(key: K, notSetValue?: unknown): R[K];
871
+ get<NSV>(key: any, notSetValue: NSV): NSV;
872
+
873
+ // https://github.com/microsoft/TypeScript/pull/39094
874
+ getIn<P extends ReadonlyArray<string | number | symbol>>(
875
+ searchKeyPath: [...P],
876
+ notSetValue?: unknown
877
+ ): RetrievePath<R, P>;
878
+
879
+ set<K extends keyof R>(key: K, value: R[K]): this;
880
+
881
+ update(updater: (value: this) => this): this;
882
+ update<K extends keyof R>(key: K, updater: (value: R[K]) => R[K]): this;
883
+ update<K extends keyof R, NSV extends R[K]>(
884
+ key: K,
885
+ notSetValue: NSV,
886
+ updater: (value: R[K]) => R[K]
887
+ ): this;
888
+
889
+ // Possible best type is MapOf<Omit<R, K>> but Omit seems to broke other function calls
890
+ // and generate recursion error with other methods (update, merge, etc.) until those functions are defined in MapOf
891
+ delete<K extends keyof R>(
892
+ key: K
893
+ ): Extract<R[K], undefined> extends never ? never : this;
894
+ remove<K extends keyof R>(
895
+ key: K
896
+ ): Extract<R[K], undefined> extends never ? never : this;
897
+
898
+ toJS(): { [K in keyof R]: DeepCopy<R[K]> };
899
+
900
+ toJSON(): { [K in keyof R]: R[K] };
901
+ }
902
+
903
+ // Loosely based off of this work.
904
+ // https://github.com/immutable-js/immutable-js/issues/1462#issuecomment-584123268
905
+
906
+ /** @ignore */
907
+ type GetMapType<S> = S extends MapOf<infer T> ? T : S;
908
+
909
+ /** @ignore */
910
+ type Head<T extends ReadonlyArray<any>> = T extends [
911
+ infer H,
912
+ ...Array<unknown>
913
+ ]
914
+ ? H
915
+ : never;
916
+
917
+ /** @ignore */
918
+ type Tail<T extends ReadonlyArray<any>> = T extends [unknown, ...infer I]
919
+ ? I
920
+ : Array<never>;
921
+
922
+ /** @ignore */
923
+ type RetrievePathReducer<
924
+ T,
925
+ C,
926
+ L extends ReadonlyArray<any>
927
+ > = C extends keyof GetMapType<T>
928
+ ? L extends []
929
+ ? GetMapType<T>[C]
930
+ : RetrievePathReducer<GetMapType<T>[C], Head<L>, Tail<L>>
931
+ : never;
932
+
933
+ /** @ignore */
934
+ type RetrievePath<
935
+ R,
936
+ P extends ReadonlyArray<string | number | symbol>
937
+ > = P extends [] ? P : RetrievePathReducer<R, Head<P>, Tail<P>>;
938
+
847
939
  interface Map<K, V> extends Collection.Keyed<K, V> {
848
940
  /**
849
941
  * The number of entries in this Map.
@@ -1061,16 +1153,17 @@ declare namespace Immutable {
1061
1153
  */
1062
1154
  merge<KC, VC>(
1063
1155
  ...collections: Array<Iterable<[KC, VC]>>
1064
- ): Map<K | KC, V | VC>;
1156
+ ): Map<K | KC, Exclude<V, VC> | VC>;
1065
1157
  merge<C>(
1066
1158
  ...collections: Array<{ [key: string]: C }>
1067
- ): Map<K | string, V | C>;
1159
+ ): Map<K | string, Exclude<V, C> | C>;
1160
+
1068
1161
  concat<KC, VC>(
1069
1162
  ...collections: Array<Iterable<[KC, VC]>>
1070
- ): Map<K | KC, V | VC>;
1163
+ ): Map<K | KC, Exclude<V, VC> | VC>;
1071
1164
  concat<C>(
1072
1165
  ...collections: Array<{ [key: string]: C }>
1073
- ): Map<K | string, V | C>;
1166
+ ): Map<K | string, Exclude<V, C> | C>;
1074
1167
 
1075
1168
  /**
1076
1169
  * Like `merge()`, `mergeWith()` returns a new Map resulting from merging
@@ -1090,10 +1183,14 @@ declare namespace Immutable {
1090
1183
  *
1091
1184
  * Note: `mergeWith` can be used in `withMutations`.
1092
1185
  */
1093
- mergeWith(
1094
- merger: (oldVal: V, newVal: V, key: K) => V,
1095
- ...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
1096
- ): this;
1186
+ mergeWith<KC, VC, VCC>(
1187
+ merger: (oldVal: V, newVal: VC, key: K) => VCC,
1188
+ ...collections: Array<Iterable<[KC, VC]>>
1189
+ ): Map<K | KC, V | VC | VCC>;
1190
+ mergeWith<C, CC>(
1191
+ merger: (oldVal: V, newVal: C, key: string) => CC,
1192
+ ...collections: Array<{ [key: string]: C }>
1193
+ ): Map<K | string, V | C | CC>;
1097
1194
 
1098
1195
  /**
1099
1196
  * Like `merge()`, but when two compatible collections are encountered with
@@ -1124,9 +1221,12 @@ declare namespace Immutable {
1124
1221
  *
1125
1222
  * Note: `mergeDeep` can be used in `withMutations`.
1126
1223
  */
1127
- mergeDeep(
1128
- ...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
1129
- ): this;
1224
+ mergeDeep<KC, VC>(
1225
+ ...collections: Array<Iterable<[KC, VC]>>
1226
+ ): Map<K | KC, V | VC>;
1227
+ mergeDeep<C>(
1228
+ ...collections: Array<{ [key: string]: C }>
1229
+ ): Map<K | string, V | C>;
1130
1230
 
1131
1231
  /**
1132
1232
  * Like `mergeDeep()`, but when two non-collections or incompatible
@@ -1594,15 +1694,32 @@ declare namespace Immutable {
1594
1694
  */
1595
1695
  merge<KC, VC>(
1596
1696
  ...collections: Array<Iterable<[KC, VC]>>
1597
- ): OrderedMap<K | KC, V | VC>;
1697
+ ): OrderedMap<K | KC, Exclude<V, VC> | VC>;
1598
1698
  merge<C>(
1599
1699
  ...collections: Array<{ [key: string]: C }>
1600
- ): OrderedMap<K | string, V | C>;
1700
+ ): OrderedMap<K | string, Exclude<V, C> | C>;
1701
+
1601
1702
  concat<KC, VC>(
1602
1703
  ...collections: Array<Iterable<[KC, VC]>>
1603
- ): OrderedMap<K | KC, V | VC>;
1704
+ ): OrderedMap<K | KC, Exclude<V, VC> | VC>;
1604
1705
  concat<C>(
1605
1706
  ...collections: Array<{ [key: string]: C }>
1707
+ ): OrderedMap<K | string, Exclude<V, C> | C>;
1708
+
1709
+ mergeWith<KC, VC, VCC>(
1710
+ merger: (oldVal: V, newVal: VC, key: K) => VCC,
1711
+ ...collections: Array<Iterable<[KC, VC]>>
1712
+ ): OrderedMap<K | KC, V | VC | VCC>;
1713
+ mergeWith<C, CC>(
1714
+ merger: (oldVal: V, newVal: C, key: string) => CC,
1715
+ ...collections: Array<{ [key: string]: C }>
1716
+ ): OrderedMap<K | string, V | C | CC>;
1717
+
1718
+ mergeDeep<KC, VC>(
1719
+ ...collections: Array<Iterable<[KC, VC]>>
1720
+ ): OrderedMap<K | KC, V | VC>;
1721
+ mergeDeep<C>(
1722
+ ...collections: Array<{ [key: string]: C }>
1606
1723
  ): OrderedMap<K | string, V | C>;
1607
1724
 
1608
1725
  // Sequence algorithms
@@ -1713,6 +1830,8 @@ declare namespace Immutable {
1713
1830
  * `Set.fromKeys()` creates a new immutable Set containing the keys from
1714
1831
  * this Collection or JavaScript Object.
1715
1832
  */
1833
+ function fromKeys<T>(iter: Collection.Keyed<T, unknown>): Set<T>;
1834
+ // tslint:disable-next-line unified-signatures
1716
1835
  function fromKeys<T>(iter: Collection<T, unknown>): Set<T>;
1717
1836
  function fromKeys(obj: { [key: string]: unknown }): Set<string>;
1718
1837
 
@@ -1936,6 +2055,8 @@ declare namespace Immutable {
1936
2055
  * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing
1937
2056
  * the keys from this Collection or JavaScript Object.
1938
2057
  */
2058
+ function fromKeys<T>(iter: Collection.Keyed<T, unknown>): OrderedSet<T>;
2059
+ // tslint:disable-next-line unified-signatures
1939
2060
  function fromKeys<T>(iter: Collection<T, unknown>): OrderedSet<T>;
1940
2061
  function fromKeys(obj: { [key: string]: unknown }): OrderedSet<string>;
1941
2062
  }
@@ -2358,8 +2479,8 @@ declare namespace Immutable {
2358
2479
  * ```
2359
2480
  */
2360
2481
  function Range(
2361
- start?: number,
2362
- end?: number,
2482
+ start: number,
2483
+ end: number,
2363
2484
  step?: number
2364
2485
  ): Seq.Indexed<number>;
2365
2486
 
package/dist/immutable.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @license
2
3
  * MIT License
3
4
  *
4
5
  * Copyright (c) 2014-present, Lee Byron and other contributors.
@@ -25,8 +26,9 @@
25
26
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
26
27
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
27
28
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {}));
28
- }(this, (function (exports) { 'use strict';
29
+ })(this, (function (exports) { 'use strict';
29
30
 
31
+ // Used for setting prototype methods that IE8 chokes on.
30
32
  var DELETE = 'delete';
31
33
 
32
34
  // Constants describing the size of trie nodes.
@@ -118,6 +120,7 @@
118
120
  return value < 0 || (value === 0 && 1 / value === -Infinity);
119
121
  }
120
122
 
123
+ // Note: value is unchanged to not break immutable-devtools.
121
124
  var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
122
125
 
123
126
  function isCollection(maybeCollection) {
@@ -1935,6 +1938,7 @@
1935
1938
  return a > b ? 1 : a < b ? -1 : 0;
1936
1939
  }
1937
1940
 
1941
+ // http://jsperf.com/copy-array-inline
1938
1942
  function arrCopy(arr, offset) {
1939
1943
  offset = offset || 0;
1940
1944
  var len = Math.max(0, arr.length - offset);
@@ -2006,6 +2010,9 @@
2006
2010
  );
2007
2011
  }
2008
2012
 
2013
+ /**
2014
+ * Converts a value to a string, adding quotes if a string was provided.
2015
+ */
2009
2016
  function quoteString(value) {
2010
2017
  try {
2011
2018
  return typeof value === 'string' ? JSON.stringify(value) : String(value);
@@ -4289,6 +4296,9 @@
4289
4296
  return allEqual && a.size === bSize;
4290
4297
  }
4291
4298
 
4299
+ /**
4300
+ * Contributes additional methods to a constructor
4301
+ */
4292
4302
  function mixin(ctor, methods) {
4293
4303
  var keyCopier = function (key) {
4294
4304
  ctor.prototype[key] = methods[key];
@@ -4571,15 +4581,22 @@
4571
4581
  */
4572
4582
  var Range = /*@__PURE__*/(function (IndexedSeq) {
4573
4583
  function Range(start, end, step) {
4584
+ if ( step === void 0 ) step = 1;
4585
+
4574
4586
  if (!(this instanceof Range)) {
4575
4587
  return new Range(start, end, step);
4576
4588
  }
4577
4589
  invariant(step !== 0, 'Cannot step a Range by 0');
4578
- start = start || 0;
4579
- if (end === undefined) {
4580
- end = Infinity;
4581
- }
4582
- step = step === undefined ? 1 : Math.abs(step);
4590
+ invariant(
4591
+ start !== undefined,
4592
+ 'You must define a start value when using Range'
4593
+ );
4594
+ invariant(
4595
+ end !== undefined,
4596
+ 'You must define an end value when using Range'
4597
+ );
4598
+
4599
+ step = Math.abs(step);
4583
4600
  if (end < start) {
4584
4601
  step = -step;
4585
4602
  }
@@ -5905,64 +5922,7 @@
5905
5922
  return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
5906
5923
  }
5907
5924
 
5908
- var version = "5.0.0-beta.3";
5909
-
5910
- var Immutable = {
5911
- version: version,
5912
-
5913
- Collection: Collection,
5914
- // Note: Iterable is deprecated
5915
- Iterable: Collection,
5916
-
5917
- Seq: Seq,
5918
- Map: Map,
5919
- OrderedMap: OrderedMap,
5920
- List: List,
5921
- Stack: Stack,
5922
- Set: Set,
5923
- OrderedSet: OrderedSet,
5924
- PairSorting: PairSorting,
5925
-
5926
- Record: Record,
5927
- Range: Range,
5928
- Repeat: Repeat,
5929
-
5930
- is: is,
5931
- fromJS: fromJS,
5932
- hash: hash,
5933
-
5934
- isImmutable: isImmutable,
5935
- isCollection: isCollection,
5936
- isKeyed: isKeyed,
5937
- isIndexed: isIndexed,
5938
- isAssociative: isAssociative,
5939
- isOrdered: isOrdered,
5940
- isValueObject: isValueObject,
5941
- isPlainObject: isPlainObject,
5942
- isSeq: isSeq,
5943
- isList: isList,
5944
- isMap: isMap,
5945
- isOrderedMap: isOrderedMap,
5946
- isStack: isStack,
5947
- isSet: isSet,
5948
- isOrderedSet: isOrderedSet,
5949
- isRecord: isRecord,
5950
-
5951
- get: get,
5952
- getIn: getIn$1,
5953
- has: has,
5954
- hasIn: hasIn$1,
5955
- merge: merge,
5956
- mergeDeep: mergeDeep$1,
5957
- mergeWith: mergeWith,
5958
- mergeDeepWith: mergeDeepWith$1,
5959
- remove: remove,
5960
- removeIn: removeIn,
5961
- set: set,
5962
- setIn: setIn$1,
5963
- update: update$1,
5964
- updateIn: updateIn$1,
5965
- };
5925
+ var version = "5.0.0-beta.5";
5966
5926
 
5967
5927
  // Note: Iterable is deprecated
5968
5928
  var Iterable = Collection;
@@ -5980,7 +5940,6 @@
5980
5940
  exports.Seq = Seq;
5981
5941
  exports.Set = Set;
5982
5942
  exports.Stack = Stack;
5983
- exports.default = Immutable;
5984
5943
  exports.fromJS = fromJS;
5985
5944
  exports.get = get;
5986
5945
  exports.getIn = getIn$1;
@@ -6016,6 +5975,4 @@
6016
5975
  exports.updateIn = updateIn$1;
6017
5976
  exports.version = version;
6018
5977
 
6019
- Object.defineProperty(exports, '__esModule', { value: true });
6020
-
6021
- })));
5978
+ }));