immutable 5.0.0-beta.4 → 5.0.0-rc.1

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 +2 -2
  2. package/dist/es/Collection.js +6 -1
  3. package/dist/es/CollectionImpl.js +11 -16
  4. package/dist/es/Hash.js +1 -0
  5. package/dist/es/Immutable.js +2 -2
  6. package/dist/es/Iterator.js +1 -0
  7. package/dist/es/List.js +7 -1
  8. package/dist/es/Map.js +4 -16
  9. package/dist/es/Math.js +1 -0
  10. package/dist/es/Operations.js +7 -6
  11. package/dist/es/OrderedMap.js +3 -1
  12. package/dist/es/OrderedSet.js +3 -1
  13. package/dist/es/PairSorting.js +1 -0
  14. package/dist/es/Range.js +16 -5
  15. package/dist/es/Record.js +3 -1
  16. package/dist/es/Repeat.js +5 -1
  17. package/dist/es/Seq.js +6 -1
  18. package/dist/es/Set.js +2 -0
  19. package/dist/es/Stack.js +2 -0
  20. package/dist/es/TrieUtils.js +2 -0
  21. package/dist/es/fromJS.js +1 -0
  22. package/dist/es/functional/get.js +1 -0
  23. package/dist/es/functional/getIn.js +1 -0
  24. package/dist/es/functional/has.js +1 -0
  25. package/dist/es/functional/hasIn.js +1 -0
  26. package/dist/es/functional/merge.js +1 -0
  27. package/dist/es/functional/remove.js +1 -0
  28. package/dist/es/functional/removeIn.js +1 -0
  29. package/dist/es/functional/set.js +1 -0
  30. package/dist/es/functional/setIn.js +1 -0
  31. package/dist/es/functional/update.js +1 -0
  32. package/dist/es/functional/updateIn.js +1 -0
  33. package/dist/es/is.js +1 -0
  34. package/dist/es/methods/asImmutable.js +1 -0
  35. package/dist/es/methods/asMutable.js +1 -0
  36. package/dist/es/methods/deleteIn.js +1 -0
  37. package/dist/es/methods/getIn.js +1 -0
  38. package/dist/es/methods/hasIn.js +1 -0
  39. package/dist/es/methods/merge.js +1 -0
  40. package/dist/es/methods/mergeDeep.js +1 -0
  41. package/dist/es/methods/mergeDeepIn.js +1 -0
  42. package/dist/es/methods/mergeIn.js +1 -0
  43. package/dist/es/methods/setIn.js +1 -0
  44. package/dist/es/methods/toObject.js +1 -0
  45. package/dist/es/methods/update.js +1 -0
  46. package/dist/es/methods/updateIn.js +1 -0
  47. package/dist/es/methods/wasAltered.js +1 -0
  48. package/dist/es/methods/withMutations.js +1 -0
  49. package/dist/es/package.json.js +2 -1
  50. package/dist/es/predicates/isAssociative.js +1 -0
  51. package/dist/es/predicates/isCollection.js +2 -0
  52. package/dist/es/predicates/isImmutable.js +1 -0
  53. package/dist/es/predicates/isIndexed.js +1 -0
  54. package/dist/es/predicates/isKeyed.js +1 -0
  55. package/dist/es/predicates/isList.js +1 -0
  56. package/dist/es/predicates/isMap.js +1 -0
  57. package/dist/es/predicates/isOrdered.js +1 -0
  58. package/dist/es/predicates/isOrderedMap.js +1 -0
  59. package/dist/es/predicates/isOrderedSet.js +1 -0
  60. package/dist/es/predicates/isRecord.js +1 -0
  61. package/dist/es/predicates/isSeq.js +1 -0
  62. package/dist/es/predicates/isSet.js +1 -0
  63. package/dist/es/predicates/isStack.js +1 -0
  64. package/dist/es/predicates/isValueObject.js +1 -0
  65. package/dist/es/toJS.js +1 -0
  66. package/dist/es/utils/arrCopy.js +3 -1
  67. package/dist/es/utils/assertNotInfinite.js +2 -1
  68. package/dist/es/utils/coerceKeyPath.js +2 -1
  69. package/dist/es/utils/deepEqual.js +2 -1
  70. package/dist/es/utils/hasOwnProperty.js +2 -1
  71. package/dist/es/utils/invariant.js +2 -1
  72. package/dist/es/utils/isArrayLike.js +2 -1
  73. package/dist/es/utils/isDataStructure.js +2 -1
  74. package/dist/es/utils/isPlainObj.js +2 -1
  75. package/dist/es/utils/mixin.js +5 -1
  76. package/dist/es/utils/quoteString.js +5 -1
  77. package/dist/es/utils/shallowCopy.js +2 -1
  78. package/dist/immutable.d.ts +14 -52
  79. package/dist/immutable.js +62 -40
  80. package/dist/immutable.js.flow +4 -2
  81. package/dist/immutable.min.js +2 -32
  82. package/package.json +1 -1
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -21,6 +22,6 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
24
- var version = "5.0.0-beta.4";
25
+ var version = "5.0.0-rc.1";
25
26
 
26
27
  export { version };
@@ -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.
@@ -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.
@@ -21,6 +22,7 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
25
+ // Note: value is unchanged to not break immutable-devtools.
24
26
  var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
25
27
 
26
28
  function isCollection(maybeCollection) {
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
package/dist/es/toJS.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.
@@ -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.
@@ -21,6 +22,7 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
25
+ // http://jsperf.com/copy-array-inline
24
26
  function arrCopy(arr, offset) {
25
27
  offset = offset || 0;
26
28
  var len = Math.max(0, arr.length - offset);
@@ -31,4 +33,4 @@ function arrCopy(arr, offset) {
31
33
  return newArr;
32
34
  }
33
35
 
34
- export default arrCopy;
36
+ export { arrCopy as default };
@@ -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.
@@ -30,4 +31,4 @@ function assertNotInfinite(size) {
30
31
  );
31
32
  }
32
33
 
33
- export default assertNotInfinite;
34
+ export { assertNotInfinite as default };
@@ -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.
@@ -36,4 +37,4 @@ function coerceKeyPath(keyPath) {
36
37
  );
37
38
  }
38
39
 
39
- export default coerceKeyPath;
40
+ export { coerceKeyPath as default };
@@ -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.
@@ -95,4 +96,4 @@ function deepEqual(a, b) {
95
96
  return allEqual && a.size === bSize;
96
97
  }
97
98
 
98
- export default deepEqual;
99
+ export { deepEqual as default };
@@ -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.
@@ -23,4 +24,4 @@
23
24
  */
24
25
  var hasOwnProperty = Object.prototype.hasOwnProperty;
25
26
 
26
- export default hasOwnProperty;
27
+ export { hasOwnProperty as default };
@@ -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,4 +26,4 @@ function invariant(condition, error) {
25
26
  if (!condition) { throw new Error(error); }
26
27
  }
27
28
 
28
- export default invariant;
29
+ export { invariant as default };
@@ -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.
@@ -40,4 +41,4 @@ function isArrayLike(value) {
40
41
  );
41
42
  }
42
43
 
43
- export default isArrayLike;
44
+ export { isArrayLike as default };
@@ -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.
@@ -35,4 +36,4 @@ function isDataStructure(value) {
35
36
  );
36
37
  }
37
38
 
38
- export default isDataStructure;
39
+ export { isDataStructure as default };
@@ -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.
@@ -48,4 +49,4 @@ function isPlainObject(value) {
48
49
  return parentProto === proto;
49
50
  }
50
51
 
51
- export default isPlainObject;
52
+ export { isPlainObject as default };
@@ -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.
@@ -21,6 +22,9 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
25
+ /**
26
+ * Contributes additional methods to a constructor
27
+ */
24
28
  function mixin(ctor, methods) {
25
29
  var keyCopier = function (key) {
26
30
  ctor.prototype[key] = methods[key];
@@ -31,4 +35,4 @@ function mixin(ctor, methods) {
31
35
  return ctor;
32
36
  }
33
37
 
34
- export default mixin;
38
+ export { mixin as default };
@@ -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.
@@ -21,6 +22,9 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
25
+ /**
26
+ * Converts a value to a string, adding quotes if a string was provided.
27
+ */
24
28
  function quoteString(value) {
25
29
  try {
26
30
  return typeof value === 'string' ? JSON.stringify(value) : String(value);
@@ -29,4 +33,4 @@ function quoteString(value) {
29
33
  }
30
34
  }
31
35
 
32
- export default quoteString;
36
+ export { quoteString as default };
@@ -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.
@@ -37,4 +38,4 @@ function shallowCopy(from) {
37
38
  return to;
38
39
  }
39
40
 
40
- export default shallowCopy;
41
+ export { shallowCopy as default };
@@ -1,3 +1,5 @@
1
+ /** @ignore we should disable this rules, but let's activate it to enable eslint first */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
1
3
  /**
2
4
  * Immutable data encourages pure functions (data-in, data-out) and lends itself
3
5
  * to much simpler application development and enabling techniques from
@@ -125,6 +127,7 @@ declare namespace Immutable {
125
127
  : string]: V extends object ? unknown : V;
126
128
  }
127
129
  : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array
130
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
128
131
  T extends Collection<infer _, infer V>
129
132
  ? Array<DeepCopy<V>>
130
133
  : T extends string | number // Iterable scalar types : should be kept as is
@@ -789,24 +792,6 @@ declare namespace Immutable {
789
792
  * ```
790
793
  */
791
794
  function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
792
-
793
- /**
794
- * Creates a new Map from alternating keys and values
795
- *
796
- * <!-- runkit:activate -->
797
- * ```js
798
- * const { Map } = require('immutable')
799
- * Map.of(
800
- * 'key', 'value',
801
- * 'numerical value', 3,
802
- * 0, 'numerical key'
803
- * )
804
- * // Map { 0: "numerical key", "key": "value", "numerical value": 3 }
805
- * ```
806
- *
807
- * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' })
808
- */
809
- function of(...keyValues: Array<unknown>): Map<unknown, unknown>;
810
795
  }
811
796
 
812
797
  /**
@@ -870,7 +855,9 @@ declare namespace Immutable {
870
855
  get<K extends keyof R>(key: K, notSetValue?: unknown): R[K];
871
856
  get<NSV>(key: any, notSetValue: NSV): NSV;
872
857
 
873
- // https://github.com/microsoft/TypeScript/pull/39094
858
+ // TODO `<const P extends ...>` can be used after dropping support for TypeScript 4.x
859
+ // reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters
860
+ // after this change, `as const` assertions can be remove from the type tests
874
861
  getIn<P extends ReadonlyArray<string | number | symbol>>(
875
862
  searchKeyPath: [...P],
876
863
  notSetValue?: unknown
@@ -1830,6 +1817,7 @@ declare namespace Immutable {
1830
1817
  * `Set.fromKeys()` creates a new immutable Set containing the keys from
1831
1818
  * this Collection or JavaScript Object.
1832
1819
  */
1820
+ function fromKeys<T>(iter: Collection.Keyed<T, unknown>): Set<T>;
1833
1821
  function fromKeys<T>(iter: Collection<T, unknown>): Set<T>;
1834
1822
  function fromKeys(obj: { [key: string]: unknown }): Set<string>;
1835
1823
 
@@ -2053,6 +2041,7 @@ declare namespace Immutable {
2053
2041
  * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing
2054
2042
  * the keys from this Collection or JavaScript Object.
2055
2043
  */
2044
+ function fromKeys<T>(iter: Collection.Keyed<T, unknown>): OrderedSet<T>;
2056
2045
  function fromKeys<T>(iter: Collection<T, unknown>): OrderedSet<T>;
2057
2046
  function fromKeys(obj: { [key: string]: unknown }): OrderedSet<string>;
2058
2047
  }
@@ -2475,8 +2464,8 @@ declare namespace Immutable {
2475
2464
  * ```
2476
2465
  */
2477
2466
  function Range(
2478
- start?: number,
2479
- end?: number,
2467
+ start: number,
2468
+ end: number,
2480
2469
  step?: number
2481
2470
  ): Seq.Indexed<number>;
2482
2471
 
@@ -3585,34 +3574,6 @@ declare namespace Immutable {
3585
3574
  * `Collection.Indexed`, or `Collection.Set`.
3586
3575
  */
3587
3576
  namespace Collection {
3588
- /**
3589
- * @deprecated use `const { isKeyed } = require('immutable')`
3590
- */
3591
- function isKeyed(
3592
- maybeKeyed: unknown
3593
- ): maybeKeyed is Collection.Keyed<unknown, unknown>;
3594
-
3595
- /**
3596
- * @deprecated use `const { isIndexed } = require('immutable')`
3597
- */
3598
- function isIndexed(
3599
- maybeIndexed: unknown
3600
- ): maybeIndexed is Collection.Indexed<unknown>;
3601
-
3602
- /**
3603
- * @deprecated use `const { isAssociative } = require('immutable')`
3604
- */
3605
- function isAssociative(
3606
- maybeAssociative: unknown
3607
- ): maybeAssociative is
3608
- | Collection.Keyed<unknown, unknown>
3609
- | Collection.Indexed<unknown>;
3610
-
3611
- /**
3612
- * @deprecated use `const { isOrdered } = require('immutable')`
3613
- */
3614
- function isOrdered(maybeOrdered: unknown): boolean;
3615
-
3616
3577
  /**
3617
3578
  * Keyed Collections have discrete keys tied to each value.
3618
3579
  *
@@ -4321,7 +4282,8 @@ declare namespace Immutable {
4321
4282
  * In case the `Collection` is empty returns the optional default
4322
4283
  * value if provided, if no default value is provided returns undefined.
4323
4284
  */
4324
- first<NSV = undefined>(notSetValue?: NSV): V | NSV;
4285
+ first<NSV>(notSetValue: NSV): V | NSV;
4286
+ first(): V | undefined;
4325
4287
 
4326
4288
  /**
4327
4289
  * In case the `Collection` is not empty returns the last element of the
@@ -4329,7 +4291,8 @@ declare namespace Immutable {
4329
4291
  * In case the `Collection` is empty returns the optional default
4330
4292
  * value if provided, if no default value is provided returns undefined.
4331
4293
  */
4332
- last<NSV = undefined>(notSetValue?: NSV): V | NSV;
4294
+ last<NSV>(notSetValue: NSV): V | NSV;
4295
+ last(): V | undefined;
4333
4296
 
4334
4297
  // Reading deep values
4335
4298
 
@@ -4921,7 +4884,6 @@ declare namespace Immutable {
4921
4884
  * returns Collection<K, V>
4922
4885
  */
4923
4886
  flatten(depth?: number): Collection<unknown, unknown>;
4924
- // tslint:disable-next-line unified-signatures
4925
4887
  flatten(shallow?: boolean): Collection<unknown, unknown>;
4926
4888
 
4927
4889
  /**