atomic-fns 0.3.5 → 0.4.3

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 (109) hide show
  1. package/README.md +1 -12
  2. package/{core → dist}/collections/BTree.d.ts +6 -6
  3. package/{core → dist}/collections/BTree.js +17 -17
  4. package/{core → dist}/collections/Heap.d.ts +3 -3
  5. package/{core → dist}/collections/Heap.js +0 -0
  6. package/dist/collections/LRUCache.d.ts +80 -0
  7. package/dist/collections/LRUCache.js +126 -0
  8. package/{core → dist}/collections/SortedMap.d.ts +2 -2
  9. package/{core → dist}/collections/SortedMap.js +0 -0
  10. package/{core → dist}/collections/SortedSet.d.ts +3 -3
  11. package/{core → dist}/collections/SortedSet.js +1 -1
  12. package/{core → dist}/collections/SortedTree.d.ts +3 -3
  13. package/{core → dist}/collections/SortedTree.js +1 -1
  14. package/{core → dist}/collections/SplayTree.d.ts +5 -5
  15. package/{core → dist}/collections/SplayTree.js +0 -0
  16. package/{core → dist}/collections/abc.d.ts +0 -0
  17. package/{core → dist}/collections/abc.js +0 -0
  18. package/{core → dist}/collections/deque.d.ts +7 -7
  19. package/{core → dist}/collections/deque.js +6 -8
  20. package/{core → dist}/collections/frozenset.d.ts +0 -0
  21. package/{core → dist}/collections/frozenset.js +3 -6
  22. package/{core → dist}/collections/index.d.ts +207 -105
  23. package/{core → dist}/collections/index.js +179 -436
  24. package/{core → dist}/functools/index.d.ts +30 -16
  25. package/{core → dist}/functools/index.js +34 -12
  26. package/dist/globals/decimal.d.ts +142 -0
  27. package/dist/globals/decimal.js +371 -0
  28. package/{core → dist}/globals/index.d.ts +26 -25
  29. package/{core → dist}/globals/index.js +16 -37
  30. package/dist/i18n/currency.d.ts +24 -0
  31. package/dist/i18n/currency.js +85 -0
  32. package/dist/i18n/date/index.d.ts +204 -0
  33. package/dist/i18n/date/index.js +530 -0
  34. package/dist/i18n/date/utils.d.ts +65 -0
  35. package/dist/i18n/date/utils.js +290 -0
  36. package/dist/i18n/duration.d.ts +112 -0
  37. package/dist/i18n/duration.js +392 -0
  38. package/dist/i18n/format.d.ts +26 -0
  39. package/dist/i18n/format.js +495 -0
  40. package/{core → dist}/i18n/index.d.ts +2 -1
  41. package/{core → dist}/i18n/index.js +2 -1
  42. package/{core → dist}/index.d.ts +0 -0
  43. package/{core → dist}/index.js +0 -0
  44. package/{core → dist}/itertools/index.d.ts +74 -46
  45. package/{core → dist}/itertools/index.js +28 -56
  46. package/{core → dist}/math/index.d.ts +9 -10
  47. package/{core → dist}/math/index.js +3 -1
  48. package/{core → dist}/operators/index.d.ts +4 -4
  49. package/{core → dist}/operators/index.js +2 -8
  50. package/{core → dist}/random/index.d.ts +1 -1
  51. package/{core → dist}/random/index.js +5 -5
  52. package/package.json +28 -42
  53. package/.editorconfig +0 -12
  54. package/.esdoc.json +0 -27
  55. package/.eslintignore +0 -1
  56. package/.eslintrc.json +0 -35
  57. package/.firebaserc +0 -5
  58. package/.prettierrc +0 -19
  59. package/core/collections/BTree.ts +0 -1340
  60. package/core/collections/Heap.ts +0 -189
  61. package/core/collections/LRUCache.d.ts +0 -152
  62. package/core/collections/LRUCache.js +0 -409
  63. package/core/collections/LRUCache.ts +0 -486
  64. package/core/collections/SortedMap.ts +0 -146
  65. package/core/collections/SortedSet.ts +0 -110
  66. package/core/collections/SortedTree.ts +0 -160
  67. package/core/collections/SplayTree.ts +0 -354
  68. package/core/collections/abc.ts +0 -176
  69. package/core/collections/deque.ts +0 -338
  70. package/core/collections/frozenset.ts +0 -37
  71. package/core/collections/index.ts +0 -1024
  72. package/core/collections/test.html +0 -10
  73. package/core/collections/typedArrays.d.ts +0 -31
  74. package/core/collections/typedArrays.js +0 -143
  75. package/core/collections/typedArrays.ts +0 -163
  76. package/core/functools/index.ts +0 -260
  77. package/core/globals/index.ts +0 -481
  78. package/core/i18n/date/format.d.ts +0 -16
  79. package/core/i18n/date/format.js +0 -307
  80. package/core/i18n/date/format.ts +0 -343
  81. package/core/i18n/date/index.d.ts +0 -224
  82. package/core/i18n/date/index.js +0 -387
  83. package/core/i18n/date/index.ts +0 -471
  84. package/core/i18n/date/test.html +0 -67
  85. package/core/i18n/index.ts +0 -8
  86. package/core/index.ts +0 -8
  87. package/core/itertools/index.ts +0 -494
  88. package/core/math/index.ts +0 -152
  89. package/core/operators/index.ts +0 -310
  90. package/core/random/index.ts +0 -66
  91. package/firebase.json +0 -10
  92. package/jasmine.json +0 -14
  93. package/tests/BTree.spec.ts +0 -143
  94. package/tests/Cache.spec.ts +0 -161
  95. package/tests/Heap.spec.ts +0 -66
  96. package/tests/SortedMap.spec.ts +0 -144
  97. package/tests/SortedSet.spec.ts +0 -84
  98. package/tests/SortedTree.spec.ts +0 -164
  99. package/tests/SplayTree.spec.ts +0 -121
  100. package/tests/collections.spec.ts +0 -288
  101. package/tests/deque.spec.ts +0 -107
  102. package/tests/globals.spec.ts +0 -270
  103. package/tests/itertools.spec.ts +0 -266
  104. package/tests/math.spec.ts +0 -25
  105. package/tests/operators.spec.ts +0 -40
  106. package/tests/random.spec.ts +0 -46
  107. package/tsconfig.json +0 -126
  108. package/tsconfig.node.json +0 -18
  109. package/tsconfig.xo.json +0 -9
package/README.md CHANGED
@@ -23,7 +23,7 @@ You may prefer this because it's:
23
23
 
24
24
  This library is available as an [npm package](https://www.npmjs.com/package/atomic-fns).
25
25
 
26
- To install the package you need to have [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) (or [yarn](https://yarnpkg.com/getting-started/install)) and then run:
26
+ To install the package you need to have [npm](https://www.npmjs.com/get-npm) (or [yarn](https://yarnpkg.com/getting-started/install)) installed and then run:
27
27
 
28
28
  ```bash
29
29
  npm install atomic-fns
@@ -47,17 +47,6 @@ uniqueId('user_')
47
47
  ...
48
48
  ```
49
49
 
50
- You could also import any individual module directly from an html page like this:
51
-
52
- ```html
53
- <script type="module">
54
- import {
55
- namedtuple, FrozenSet, SortedSet, SortedMap
56
- } from 'https://unpkg.com/atomic-fns/core/collections';
57
- // your code goes here...
58
- </script>
59
- ```
60
-
61
50
  See the full list of [modules](https://atomic-fns.dev/modules.html).
62
51
 
63
52
  ## Data model
@@ -81,7 +81,7 @@ export declare class BTree<K = any, V = any> extends Mapping<K, V> {
81
81
  * @param firstKey: Minimum key to include in the output. */
82
82
  keys(firstKey?: K): IterableIterator<K>;
83
83
  /** Gets the lowest key in the tree. Complexity: O(log size) */
84
- minKey(): K | undefined;
84
+ minKey(): K;
85
85
  /** Gets the highest key in the tree. Complexity: O(1) */
86
86
  maxKey(): K;
87
87
  /** Returns a new iterator for iterating the values of each pair in order by key.
@@ -166,11 +166,11 @@ export declare class BTree<K = any, V = any> extends Mapping<K, V> {
166
166
  * @param includeHigh If the `high` key is present, `onFound` is called for
167
167
  * that final pair if and only if this parameter is true.
168
168
  * @param onFound A function that is called for each key-value pair. This
169
- * function can return {break:R} to stop early with result R.
169
+ * function can return {done:R} to stop early with result R.
170
170
  * @param initialCounter Initial third argument of onFound. This value
171
171
  * increases by one each time `onFound` is called. Default: 0
172
172
  * @returns The number of values found, or R if the callback returned
173
- * `{break:R}` to stop early.
173
+ * `{done:R}` to stop early.
174
174
  * @description Computational complexity: O(number of items scanned + log size)
175
175
  */
176
176
  rangeForEach<R = number>(low: K, high: K, includeHigh: boolean, onFound?: Iteratee<K, V>, initialCounter?: number): R | number;
@@ -190,13 +190,13 @@ export declare class BTree<K = any, V = any> extends Mapping<K, V> {
190
190
  * @param onFound A function that is called for each key-value pair. This
191
191
  * function can return `{value:v}` to change the value associated
192
192
  * with the current key, `{delete:true}` to delete the current pair,
193
- * `{break:R}` to stop early with result R, or it can return nothing
193
+ * `{done:R}` to stop early with result R, or it can return nothing
194
194
  * (undefined or {}) to cause no effect and continue iterating.
195
- * `{break:R}` can be combined with one of the other two commands.
195
+ * `{done:R}` can be combined with one of the other two commands.
196
196
  * The third argument `counter` is the number of items iterated
197
197
  * previously; it equals 0 when `onFound` is called the first time.
198
198
  * @returns The number of values scanned, or R if the callback returned
199
- * `{break:R}` to stop early.
199
+ * `{done:R}` to stop early.
200
200
  * @description
201
201
  * Computational complexity: O(number of items scanned + log size)
202
202
  * Note: if the tree has been cloned with clone(), any shared
@@ -3,7 +3,7 @@ import { compare } from '../operators/index.js';
3
3
  import { Mapping } from './abc.js';
4
4
  const Delete = { delete: true };
5
5
  const DeleteRange = () => Delete;
6
- const Break = { break: true };
6
+ const Break = { done: true };
7
7
  const EmptyArray = [];
8
8
  const ReusedArray = []; // assumed thread-local
9
9
  // Optimization: this array of `undefined`s is used instead of a normal
@@ -164,7 +164,7 @@ class BNode {
164
164
  }
165
165
  else {
166
166
  // Key already exists
167
- if (overwrite !== false) {
167
+ if (overwrite) {
168
168
  if (value !== undefined)
169
169
  this.reifyValues();
170
170
  // usually this is a no-op, but some users may wish to edit the key
@@ -252,7 +252,7 @@ class BNode {
252
252
  iHigh = this.indexOf(high, -1, cmp);
253
253
  if (iHigh < 0)
254
254
  iHigh = ~iHigh;
255
- else if (includeHigh === true)
255
+ else if (includeHigh)
256
256
  iHigh++;
257
257
  }
258
258
  const keys = this.keys;
@@ -263,7 +263,7 @@ class BNode {
263
263
  const result = onFound(key, values[i], count++);
264
264
  if (result !== undefined) {
265
265
  if (editMode) {
266
- if (key !== keys[i] || this.isShared === true)
266
+ if (key !== keys[i] || this.isShared)
267
267
  throw new Error('BTree illegally changed or cloned in editRange');
268
268
  if (result.delete) {
269
269
  this.keys.splice(i, 1);
@@ -277,7 +277,7 @@ class BNode {
277
277
  values[i] = result.value;
278
278
  }
279
279
  }
280
- if (result.break !== undefined)
280
+ if (result.done !== undefined)
281
281
  return result;
282
282
  }
283
283
  }
@@ -344,23 +344,23 @@ export class BTree extends Mapping {
344
344
  // * the callback is backwards: value first, then key. Call forEachPair
345
345
  // * instead to receive the key as the first argument.
346
346
  // * @returns the number of values that were sent to the callback,
347
- // * or the R value if the callback returned {break:R}. */
347
+ // * or the R value if the callback returned {done:R}. */
348
348
  // forEach<R = number>(iteratee: Iteratee<V, K>): R | number {
349
349
  // return this.forEachPair((k, v) => iteratee(v as V, k, this))
350
350
  // }
351
351
  // /** Runs a function for each key-value pair, in order from smallest to
352
- // * largest key. The callback can return {break:R} (where R is any value
352
+ // * largest key. The callback can return {done:R} (where R is any value
353
353
  // * except undefined) to stop immediately and return R from forEachPair.
354
354
  // * @param onFound A function that is called for each key-value pair. This
355
- // * function can return {break:R} to stop early with result R.
356
- // * The reason that you must return {break:R} instead of simply R
355
+ // * function can return {done:R} to stop early with result R.
356
+ // * The reason that you must return {done:R} instead of simply R
357
357
  // * itself is for consistency with editRange(), which allows
358
358
  // * multiple actions, not just breaking.
359
359
  // * @param initialCounter This is the value of the third argument of
360
360
  // * `onFound` the first time it is called. The counter increases
361
361
  // * by one each time `onFound` is called. Default value: 0
362
362
  // * @returns the number of pairs sent to the callback (plus initialCounter,
363
- // * if you provided one). If the callback returned {break:R} then
363
+ // * if you provided one). If the callback returned {done:R} then
364
364
  // * the R value is returned instead. */
365
365
  // private forEachPair<R = number>(callback: Iteratee<K, V>, initialCounter?: number): R | number {
366
366
  // const low = this.minKey()
@@ -758,16 +758,16 @@ export class BTree extends Mapping {
758
758
  * @param includeHigh If the `high` key is present, `onFound` is called for
759
759
  * that final pair if and only if this parameter is true.
760
760
  * @param onFound A function that is called for each key-value pair. This
761
- * function can return {break:R} to stop early with result R.
761
+ * function can return {done:R} to stop early with result R.
762
762
  * @param initialCounter Initial third argument of onFound. This value
763
763
  * increases by one each time `onFound` is called. Default: 0
764
764
  * @returns The number of values found, or R if the callback returned
765
- * `{break:R}` to stop early.
765
+ * `{done:R}` to stop early.
766
766
  * @description Computational complexity: O(number of items scanned + log size)
767
767
  */
768
768
  rangeForEach(low, high, includeHigh, onFound, initialCounter) {
769
769
  const r = this.root.forRange(low, high, includeHigh, false, this, initialCounter || 0, onFound);
770
- return typeof r === 'number' ? r : r.break;
770
+ return typeof r === 'number' ? r : r.done;
771
771
  }
772
772
  /**
773
773
  * Scans and potentially modifies values for a subsequence of keys.
@@ -785,13 +785,13 @@ export class BTree extends Mapping {
785
785
  * @param onFound A function that is called for each key-value pair. This
786
786
  * function can return `{value:v}` to change the value associated
787
787
  * with the current key, `{delete:true}` to delete the current pair,
788
- * `{break:R}` to stop early with result R, or it can return nothing
788
+ * `{done:R}` to stop early with result R, or it can return nothing
789
789
  * (undefined or {}) to cause no effect and continue iterating.
790
- * `{break:R}` can be combined with one of the other two commands.
790
+ * `{done:R}` can be combined with one of the other two commands.
791
791
  * The third argument `counter` is the number of items iterated
792
792
  * previously; it equals 0 when `onFound` is called the first time.
793
793
  * @returns The number of values scanned, or R if the callback returned
794
- * `{break:R}` to stop early.
794
+ * `{done:R}` to stop early.
795
795
  * @description
796
796
  * Computational complexity: O(number of items scanned + log size)
797
797
  * Note: if the tree has been cloned with clone(), any shared
@@ -804,7 +804,7 @@ export class BTree extends Mapping {
804
804
  this.root = root = root.clone();
805
805
  try {
806
806
  const r = root.forRange(low, high, includeHigh, true, this, initialCounter || 0, onFound);
807
- return typeof r === 'number' ? r : r.break;
807
+ return typeof r === 'number' ? r : r.done;
808
808
  }
809
809
  finally {
810
810
  let isShared;
@@ -14,7 +14,7 @@ export declare class Heap<T> extends Collection {
14
14
  * @param {Comparer} [cmp=compare] Compare function. Defaults to smaller values first.
15
15
  */
16
16
  constructor(container?: Iterable<T>, cmp?: Comparer);
17
- at(n: number): T | undefined;
17
+ at(n: number): T;
18
18
  get size(): number;
19
19
  clear(): void;
20
20
  /**
@@ -25,11 +25,11 @@ export declare class Heap<T> extends Collection {
25
25
  /**
26
26
  * Removes the top element.
27
27
  */
28
- pop(): T | undefined;
28
+ pop(): T;
29
29
  /**
30
30
  * Accesses the top element.
31
31
  */
32
- top(): T | undefined;
32
+ top(): T;
33
33
  /**
34
34
  * Check if element is in heap.
35
35
  * @param item The item want to find.
File without changes
@@ -0,0 +1,80 @@
1
+ import { Mapping } from './abc.js';
2
+ /**
3
+ * Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
4
+ * @template K, V
5
+ */
6
+ export declare class LRUCache<K = any, V = any> extends Mapping<K, V> {
7
+ protected items: Map<K, V>;
8
+ protected maxSize: number;
9
+ /**
10
+ * Creates a new instance of fixed size.
11
+ * @param {number} capacity
12
+ */
13
+ constructor(capacity?: number);
14
+ /**
15
+ * Adds a new element with a specified `key` and `value` to the cache. If an element with the same key already exists, the element will be updated.
16
+ * @param {K} key
17
+ * @param {V} value
18
+ * @returns {this}
19
+ */
20
+ set(key: K, value: V): this;
21
+ /**
22
+ * This is just an alias of {@link LRUCache.set}.
23
+ * @param {K} key The key to add (note value will be `undefined`)
24
+ * @returns {this}
25
+ */
26
+ add(key: K): this;
27
+ /**
28
+ * Returns `true` if the specified `key` is found on the cache.
29
+ * @param {K} key
30
+ * @returns {boolean}
31
+ */
32
+ contains(key: K): boolean;
33
+ /**
34
+ * Get the value associated with the specified `key`, or `undefined` it not found.
35
+ * @param {K} key
36
+ * @returns {?V} The associated value or `undefined`
37
+ */
38
+ get(key: K): V;
39
+ /**
40
+ * Removes all keys and values from the cache.
41
+ * @returns {this}
42
+ */
43
+ clear(): this;
44
+ /**
45
+ * Removes a key from the cache and returns `true` if the key existed or `false` otherwise.
46
+ * @param {K} key
47
+ * @returns {boolean} `true` if the key existed and was removed
48
+ */
49
+ delete(key: K): boolean;
50
+ /**
51
+ * Removes the value associated with the specified `key` from the cache and returns the removed value if the key existed.
52
+ * @param {K} key
53
+ * @returns {?V} The value if it was removed or `undefined`.
54
+ */
55
+ remove(key: K): V;
56
+ /**
57
+ * Returns the total number of elements in the cache.
58
+ */
59
+ get size(): number;
60
+ /**
61
+ * Returns the total capacity of the cache.
62
+ */
63
+ get capacity(): number;
64
+ /**
65
+ * Returns an iterable of all the keys in the cache, in insertion order.
66
+ * @returns {IterableIterator<K>}
67
+ */
68
+ keys(): IterableIterator<K>;
69
+ /**
70
+ * Returns an iterable of all the values in the cache, in insertion order.
71
+ * @returns {IterableIterator<V>}
72
+ */
73
+ values(): IterableIterator<V>;
74
+ /**
75
+ * Returns an iterable of all the [key, value] pairs in the cache, in insertion order.
76
+ * @returns {IterableIterator<[K, V]>}
77
+ */
78
+ entries(): IterableIterator<[K, V]>;
79
+ [Symbol.iterator](): IterableIterator<[K, V]>;
80
+ }
@@ -0,0 +1,126 @@
1
+ import { Mapping } from './abc.js';
2
+ /**
3
+ * Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
4
+ * @template K, V
5
+ */
6
+ export class LRUCache extends Mapping {
7
+ items = new Map();
8
+ maxSize;
9
+ /**
10
+ * Creates a new instance of fixed size.
11
+ * @param {number} capacity
12
+ */
13
+ constructor(capacity = 1024) {
14
+ super();
15
+ this.maxSize = capacity;
16
+ }
17
+ /**
18
+ * Adds a new element with a specified `key` and `value` to the cache. If an element with the same key already exists, the element will be updated.
19
+ * @param {K} key
20
+ * @param {V} value
21
+ * @returns {this}
22
+ */
23
+ set(key, value) {
24
+ if (this.items.size === this.maxSize) {
25
+ // Because ES6 maps remember insertion order, we can evict the first key
26
+ const lastKey = this.items.keys().next().value;
27
+ this.items.delete(lastKey);
28
+ }
29
+ // Delete the previous key to update the new insertion order
30
+ this.items.delete(key);
31
+ this.items.set(key, value);
32
+ return this;
33
+ }
34
+ /**
35
+ * This is just an alias of {@link LRUCache.set}.
36
+ * @param {K} key The key to add (note value will be `undefined`)
37
+ * @returns {this}
38
+ */
39
+ add(key) {
40
+ return this.set(key, undefined);
41
+ }
42
+ /**
43
+ * Returns `true` if the specified `key` is found on the cache.
44
+ * @param {K} key
45
+ * @returns {boolean}
46
+ */
47
+ contains(key) {
48
+ return this.items.has(key);
49
+ }
50
+ /**
51
+ * Get the value associated with the specified `key`, or `undefined` it not found.
52
+ * @param {K} key
53
+ * @returns {?V} The associated value or `undefined`
54
+ */
55
+ get(key) {
56
+ if (this.items.has(key)) {
57
+ const value = this.items.get(key);
58
+ // Delete the previous key to update the new insertion order
59
+ this.items.delete(key);
60
+ this.items.set(key, value);
61
+ return value;
62
+ }
63
+ }
64
+ /**
65
+ * Removes all keys and values from the cache.
66
+ * @returns {this}
67
+ */
68
+ clear() {
69
+ this.items.clear();
70
+ return this;
71
+ }
72
+ /**
73
+ * Removes a key from the cache and returns `true` if the key existed or `false` otherwise.
74
+ * @param {K} key
75
+ * @returns {boolean} `true` if the key existed and was removed
76
+ */
77
+ delete(key) {
78
+ return this.items.delete(key);
79
+ }
80
+ /**
81
+ * Removes the value associated with the specified `key` from the cache and returns the removed value if the key existed.
82
+ * @param {K} key
83
+ * @returns {?V} The value if it was removed or `undefined`.
84
+ */
85
+ remove(key) {
86
+ const value = this.items.get(key);
87
+ this.items.delete(key);
88
+ return value;
89
+ }
90
+ /**
91
+ * Returns the total number of elements in the cache.
92
+ */
93
+ get size() {
94
+ return this.items.size;
95
+ }
96
+ /**
97
+ * Returns the total capacity of the cache.
98
+ */
99
+ get capacity() {
100
+ return this.maxSize;
101
+ }
102
+ /**
103
+ * Returns an iterable of all the keys in the cache, in insertion order.
104
+ * @returns {IterableIterator<K>}
105
+ */
106
+ keys() {
107
+ return this.items.keys();
108
+ }
109
+ /**
110
+ * Returns an iterable of all the values in the cache, in insertion order.
111
+ * @returns {IterableIterator<V>}
112
+ */
113
+ values() {
114
+ return this.items.values();
115
+ }
116
+ /**
117
+ * Returns an iterable of all the [key, value] pairs in the cache, in insertion order.
118
+ * @returns {IterableIterator<[K, V]>}
119
+ */
120
+ entries() {
121
+ return this.items.entries();
122
+ }
123
+ [Symbol.iterator]() {
124
+ return this.entries();
125
+ }
126
+ }
@@ -36,12 +36,12 @@ export declare class SortedMap<K, V> extends Mapping<K, V> {
36
36
  * Returns the smallest key in the tree.
37
37
  * @returns {?K}
38
38
  */
39
- min(): K | undefined;
39
+ min(): K;
40
40
  /**
41
41
  * Returns the largest key in the tree.
42
42
  * @returns {?K}
43
43
  */
44
- max(): K | undefined;
44
+ max(): K;
45
45
  /**
46
46
  * Returns `true` if the `key` existed in the map and was removed.
47
47
  * @param {K} key
File without changes
@@ -1,7 +1,7 @@
1
1
  import { Collection } from './abc.js';
2
2
  /**
3
3
  * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
4
- * @see {@link Compare}
4
+ * @see {@link Comparable}
5
5
  * @see {@link Ordered}
6
6
  * @template K, V
7
7
  */
@@ -23,12 +23,12 @@ export declare class SortedSet<T> extends Collection {
23
23
  * Returns the smallest value in the set.
24
24
  * @returns {?T}
25
25
  */
26
- min(): T | undefined;
26
+ min(): T;
27
27
  /**
28
28
  * Returns the largest value in the set.
29
29
  * @returns {?T}
30
30
  */
31
- max(): T | undefined;
31
+ max(): T;
32
32
  /**
33
33
  * Removes the value from the set and returns `true` if the value was found and removed.
34
34
  * @param {T} value
@@ -2,7 +2,7 @@ import { Collection } from './abc.js';
2
2
  import { SplayTree } from './SplayTree.js';
3
3
  /**
4
4
  * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
5
- * @see {@link Compare}
5
+ * @see {@link Comparable}
6
6
  * @see {@link Ordered}
7
7
  * @template K, V
8
8
  */
@@ -2,7 +2,7 @@ import { Comparer } from '../operators/index.js';
2
2
  import { Mapping } from './abc.js';
3
3
  /**
4
4
  * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
- * @see {@link Compare}
5
+ * @see {@link Comparable}
6
6
  * @see {@link Ordered}
7
7
  * @template K, V
8
8
  */
@@ -25,7 +25,7 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
25
25
  * @param {K} key
26
26
  * @returns {?V} The key value or `undefined`.
27
27
  */
28
- get(key: K): V | undefined;
28
+ get(key: K): V;
29
29
  /**
30
30
  * Sets the value for the given `key`.
31
31
  * @param {K} key
@@ -37,7 +37,7 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
37
37
  * Returns the smallest key in the tree.
38
38
  * @returns {?K}
39
39
  */
40
- min(): K | undefined;
40
+ min(): K;
41
41
  /**
42
42
  * Returns the largest key in the tree.
43
43
  * @returns {?K}
@@ -2,7 +2,7 @@ import { Mapping } from './abc.js';
2
2
  import { BTree } from './BTree.js';
3
3
  /**
4
4
  * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
- * @see {@link Compare}
5
+ * @see {@link Comparable}
6
6
  * @see {@link Ordered}
7
7
  * @template K, V
8
8
  */
@@ -31,7 +31,7 @@ export declare class SplayTree<K, V = any> extends Mapping<K, V> {
31
31
  * @param p When an element is accessed, with probability `p` splay the tree. With probability `1 - p`, leave the tree as it is.
32
32
  */
33
33
  constructor(compareFn?: any, p?: number);
34
- top(): K | undefined;
34
+ top(): K;
35
35
  get size(): number;
36
36
  empty(): boolean;
37
37
  get height(): any;
@@ -53,23 +53,23 @@ export declare class SplayTree<K, V = any> extends Mapping<K, V> {
53
53
  * @param {K} key The key to remove.
54
54
  * @returns {V} The removed value associated with `key`.
55
55
  */
56
- remove(key: K): V | undefined;
56
+ remove(key: K): V;
57
57
  /**
58
58
  * Returns the minimum key in the tree or subtree.
59
59
  * @returns The minimum key.
60
60
  */
61
- min(root?: Node<K, V> | undefined): K | undefined;
61
+ min(root?: Node<K, V>): K;
62
62
  /**
63
63
  * Returns the maximum key in the tree or subtree.
64
64
  * @returns The maximum key.
65
65
  */
66
- max(root?: Node<K, V> | undefined): K | undefined;
66
+ max(root?: Node<K, V>): K;
67
67
  /**
68
68
  * Returns the largest key that is less than a given key.
69
69
  * @param key The given key
70
70
  * @returns The largest key found or `undefined`.
71
71
  */
72
- lowerBound(key: any): K | Node<K, V> | undefined;
72
+ lowerBound(key: any): K | Node<K, V>;
73
73
  /**
74
74
  * This is the simplified top-down splaying method proposed by Sleator and Tarjan in {@link https://doi.org/10.1145%2F3828.3835 Self-Adjusting Binary Search Trees}.
75
75
  * @param key
File without changes
File without changes
File without changes
@@ -44,28 +44,28 @@ export declare class Deque<T = any> extends Sequence<T> {
44
44
  * Removes and returns the element at the end of the deque.
45
45
  * @returns {?T} Returns the popped item.
46
46
  */
47
- pop(): T | undefined;
47
+ pop(): T;
48
48
  /**
49
49
  * Alias of {@link Deque.pop}
50
50
  * @returns {?T} Returns the popped item.
51
51
  */
52
- remove(): T | undefined;
52
+ remove(): T;
53
53
  /**
54
54
  * Removes and returns the element at the beginning of the deque.
55
55
  * @returns {?T} Returns the removed deque element.
56
56
  */
57
- popleft(): T | undefined;
57
+ popleft(): T;
58
58
  /**
59
59
  * Returns the element at the beginning of the deque.
60
60
  * @returns {?T} The element if exists
61
61
  */
62
- first(): T | undefined;
62
+ first(): T;
63
63
  /**
64
64
  * Returns the element at a specified index position in the deque.
65
65
  * @param {number} index The given index
66
66
  * @returns {?T} The element if exists
67
67
  */
68
- get(index: any): T | undefined;
68
+ get(index: any): T;
69
69
  /**
70
70
  * Update the element at a given `index`.
71
71
  * @param {number} index The given index
@@ -82,7 +82,7 @@ export declare class Deque<T = any> extends Sequence<T> {
82
82
  * @param {Iteratee<T>} iteratee A function that will be invoked per element
83
83
  * @returns {?T} The element if exists
84
84
  */
85
- find(iteratee: Iteratee<T>): T | undefined;
85
+ find(iteratee: Iteratee<T>): T;
86
86
  /**
87
87
  * Calls `iteratee` function for every element in the deque.
88
88
  * @param {Iteratee<T>} iteratee A function that will be invoked per element
@@ -111,7 +111,7 @@ export declare class Deque<T = any> extends Sequence<T> {
111
111
  * Creates an iterator of `[index, value]` pairs for all elements in the deque.
112
112
  * @returns {Iterator}
113
113
  */
114
- entries(): Iterator<[number, T], any, undefined> & Iterable<[number, T]>;
114
+ entries(): Iterable<[number, T]> & Iterator<[number, T], any, undefined>;
115
115
  [Symbol.iterator](): Iterable<T>;
116
116
  inspect(): any;
117
117
  }
@@ -228,17 +228,15 @@ export class Deque extends Sequence {
228
228
  return IterableIterator(() => {
229
229
  if (j >= l)
230
230
  return {
231
- done: true
231
+ done: true,
232
+ value: undefined
232
233
  };
233
234
  const value = items[i];
234
235
  i++;
235
236
  j++;
236
237
  if (i === c)
237
238
  i = 0;
238
- return {
239
- value,
240
- done: false
241
- };
239
+ return { value };
242
240
  });
243
241
  }
244
242
  /**
@@ -260,15 +258,15 @@ export class Deque extends Sequence {
260
258
  return IterableIterator(() => {
261
259
  if (j >= l)
262
260
  return {
263
- done: true
261
+ done: true,
262
+ value: undefined
264
263
  };
265
264
  const value = items[i];
266
265
  i++;
267
266
  if (i === c)
268
267
  i = 0;
269
268
  return {
270
- value: [j++, value],
271
- done: false
269
+ value: [j++, value]
272
270
  };
273
271
  });
274
272
  }
File without changes
@@ -13,18 +13,15 @@ export class FrozenSet extends Set {
13
13
  }
14
14
  /** @private */
15
15
  add() {
16
- throw TypeError('FrozenSet cannot be modified.');
17
- return this; // eslint-disable-line
16
+ return this;
18
17
  }
19
18
  /** @private */
20
19
  delete() {
21
- throw TypeError('FrozenSet cannot be modified.');
22
- return false; // eslint-disable-line
20
+ return false;
23
21
  }
24
22
  /** @private */
25
23
  clear() {
26
- throw TypeError('FrozenSet cannot be modified.');
27
- return this; // eslint-disable-line
24
+ return this;
28
25
  }
29
26
  /** @private */
30
27
  freeze() {