atomic-fns 1.1.7 → 1.2.0
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 +51 -12
- package/dist/collections/BTree.d.ts +11 -10
- package/dist/collections/BTree.js +58 -80
- package/dist/collections/Heap.js +1 -1
- package/dist/collections/LRUCache.d.ts +6 -3
- package/dist/collections/LRUCache.js +24 -11
- package/dist/collections/SortedMap.js +2 -2
- package/dist/collections/SortedTree.d.ts +2 -2
- package/dist/collections/SortedTree.js +3 -2
- package/dist/collections/SplayTree.d.ts +7 -5
- package/dist/collections/SplayTree.js +39 -26
- package/dist/collections/Trie.d.ts +1 -1
- package/dist/collections/Trie.js +26 -26
- package/dist/collections/deque.d.ts +1 -1
- package/dist/collections/deque.js +17 -10
- package/dist/collections/frozenset.js +4 -1
- package/dist/collections/index.d.ts +13 -32
- package/dist/collections/index.js +210 -82
- package/dist/decimal/index.d.ts +5 -2
- package/dist/decimal/index.js +63 -27
- package/dist/functools/index.d.ts +6 -30
- package/dist/functools/index.js +24 -56
- package/dist/globals/index.d.ts +3 -20
- package/dist/globals/index.js +23 -39
- package/dist/i18n/currency.d.ts +3 -0
- package/dist/i18n/currency.js +22 -7
- package/dist/i18n/date/index.d.ts +17 -10
- package/dist/i18n/date/index.js +79 -58
- package/dist/i18n/date/utils.d.ts +4 -5
- package/dist/i18n/date/utils.js +15 -113
- package/dist/i18n/duration.d.ts +11 -10
- package/dist/i18n/duration.js +38 -32
- package/dist/i18n/format.d.ts +5 -2
- package/dist/i18n/format.js +81 -209
- package/dist/i18n/index.d.ts +2 -1
- package/dist/itertools/index.d.ts +9 -13
- package/dist/itertools/index.js +38 -41
- package/dist/math/index.d.ts +10 -27
- package/dist/math/index.js +16 -33
- package/dist/operators/index.d.ts +1 -5
- package/dist/operators/index.js +60 -40
- package/dist/random/index.js +9 -6
- package/dist/string/index.d.ts +1 -1
- package/dist/string/index.js +2 -4
- package/dist/types.d.ts +3 -3
- package/package.json +16 -21
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module collections
|
|
5
5
|
*/
|
|
6
6
|
import { compare } from '../operators/index.js';
|
|
7
|
-
import { Iteratee } from '../types';
|
|
7
|
+
import type { Iteratee } from '../types.js';
|
|
8
8
|
export * from './abc.js';
|
|
9
9
|
export * from './BTree.js';
|
|
10
10
|
export * from './deque.js';
|
|
@@ -38,7 +38,6 @@ export declare function compact<T>(arr: T): Partial<T>;
|
|
|
38
38
|
count([6.1, 4.2, 6.3], Math.floor);
|
|
39
39
|
// { '4': 1, '6': 2 }
|
|
40
40
|
|
|
41
|
-
// property iteratee shorthand.
|
|
42
41
|
count(['one', 'two', 'three'], x => x.length);
|
|
43
42
|
// { '3': 2, '5': 1 }
|
|
44
43
|
```
|
|
@@ -153,7 +152,7 @@ forEach({ 'a': 1, 'b': 2 }, (value, key) => {
|
|
|
153
152
|
```
|
|
154
153
|
* @param {Array|Object} collection The collection to iterate over.
|
|
155
154
|
* @param {Iteratee} fn The function invoked per iteration.
|
|
156
|
-
* @returns {
|
|
155
|
+
* @returns {void}
|
|
157
156
|
* @see {@link forEachRight}
|
|
158
157
|
* @see {@link filter}
|
|
159
158
|
* @see {@link map}
|
|
@@ -187,7 +186,7 @@ forEachRight([1, 2], console.log)
|
|
|
187
186
|
```
|
|
188
187
|
* @param {Array|Object} collection The collection to iterate over.
|
|
189
188
|
* @param {Iteratee} fn The function invoked per iteration.
|
|
190
|
-
* @returns {
|
|
189
|
+
* @returns {void}
|
|
191
190
|
* @see {@link forEach}
|
|
192
191
|
* @see {@link filter}
|
|
193
192
|
* @see {@link map}
|
|
@@ -286,7 +285,7 @@ pick(object, x => isNumber(x))
|
|
|
286
285
|
export declare function pick<T>(obj: T, paths: Iteratee): Partial<T>;
|
|
287
286
|
export declare function pick<T>(obj: T, paths: PropertyKey[]): Partial<T>;
|
|
288
287
|
/**
|
|
289
|
-
* The opposite of {@link pick} - this method creates an object composed of the own
|
|
288
|
+
* The opposite of {@link pick} - this method creates an object composed of the own enumerable properties of `object` that are not omitted.
|
|
290
289
|
* @example
|
|
291
290
|
```js
|
|
292
291
|
let object = { 'a': 1, 'b': '2', 'c': 3 }
|
|
@@ -410,27 +409,9 @@ export declare function lastIndexOf<T>(obj: T[], value: T, start?: number): numb
|
|
|
410
409
|
* @param {*} value
|
|
411
410
|
* @param {boolean} [deep=false]
|
|
412
411
|
* @return The clone value
|
|
413
|
-
* @see {@link cloneArray}
|
|
414
|
-
* @see {@link cloneTypedArray}
|
|
415
412
|
*/
|
|
416
413
|
export declare function clone<T>(value: T, deep?: boolean): T;
|
|
417
414
|
export declare function clone<T>(value: T[], deep?: boolean): T[];
|
|
418
|
-
/**
|
|
419
|
-
* Clones an array. If `deep` is `false` (default) the clone will be shallow. Otherwise {@link https://developer.mozilla.org/en-US/docs/Web/API/structuredClone structuredClone} is used.
|
|
420
|
-
* @param arr The array to clone
|
|
421
|
-
* @param [deep=false] Creates a deep clone using `structuredClone` if true.
|
|
422
|
-
* @returns The new array
|
|
423
|
-
* @see {@link clone}
|
|
424
|
-
*/
|
|
425
|
-
export declare function cloneArray<T>(arr: T[], deep?: boolean): T[];
|
|
426
|
-
/**
|
|
427
|
-
* Clones a typed array. If `deep` is `false` (default) the clone will be shallow. Otherwise {@link https://developer.mozilla.org/en-US/docs/Web/API/structuredClone structuredClone} is used.
|
|
428
|
-
* @param arr The array to clone
|
|
429
|
-
* @param [deep=false] Creates a deep clone using `structuredClone` if true.
|
|
430
|
-
* @returns The new array
|
|
431
|
-
* @see {@link clone}
|
|
432
|
-
*/
|
|
433
|
-
export declare function cloneTypedArray(typedArray: any, isDeep?: boolean): any;
|
|
434
415
|
/**
|
|
435
416
|
* Creates a duplicate-free version of an array, using a `Set` for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is not guaranteed.
|
|
436
417
|
* @param arr The array containing duplicated elements
|
|
@@ -456,7 +437,7 @@ export declare function uniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
|
|
|
456
437
|
* @returns Returns the new duplicate free array
|
|
457
438
|
* @example
|
|
458
439
|
```js
|
|
459
|
-
|
|
440
|
+
sortedUniq([2, 1, 2])
|
|
460
441
|
// [1, 2]
|
|
461
442
|
```
|
|
462
443
|
* @see {@link uniq}
|
|
@@ -464,7 +445,7 @@ uniq([2, 1, 2])
|
|
|
464
445
|
export declare function sortedUniq<T>(arr: Iterable<T>, fn?: Iteratee<T>): T[];
|
|
465
446
|
export declare function sortedUniq<T>(arr: Iterable<T>, fn?: PropertyKey): T[];
|
|
466
447
|
/**
|
|
467
|
-
* Recursively merges own
|
|
448
|
+
* Recursively merges own enumerable string keyed properties of source objects into the destination object. Source properties that resolve to `undefined` are skipped if a destination value exists. Array and plain object properties are merged recursively. Other objects and value types are overridden by assignment. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.
|
|
468
449
|
*
|
|
469
450
|
* Note: this method mutates `object`
|
|
470
451
|
*
|
|
@@ -542,7 +523,7 @@ export declare function union<T>(...args: Array<Iterable<T>>): Generator<T>;
|
|
|
542
523
|
* Creates an object composed of keys generated from the results of running each element of `arr` thru `func`. The order of grouped values is determined by the order they occur in `arr`. The corresponding value of each key is an array of elements responsible for generating the key.
|
|
543
524
|
*
|
|
544
525
|
* @param arr The collection to iterate over.
|
|
545
|
-
* @param [func=
|
|
526
|
+
* @param [func=identity] The iteratee to transform keys.
|
|
546
527
|
* @returns Returns the aggregated object.
|
|
547
528
|
*
|
|
548
529
|
* @example
|
|
@@ -563,14 +544,14 @@ export declare function groupBy<T>(arr: Object, fn: PropertyKey): Record<Propert
|
|
|
563
544
|
* Similar to {@link groupBy} but it returns a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map Map} object with the results.
|
|
564
545
|
*
|
|
565
546
|
* @param arr The collection to iterate over.
|
|
566
|
-
* @param {Function | PropertyKey} [func=
|
|
547
|
+
* @param {Function | PropertyKey} [func=identity] The iteratee to transform keys.
|
|
567
548
|
* @returns {Map} Returns the aggregated map object.
|
|
568
549
|
* @template K, V
|
|
569
550
|
*
|
|
570
551
|
* @example
|
|
571
552
|
```js
|
|
572
553
|
groupByMap([6.1, 4.2, 6.3], Math.floor)
|
|
573
|
-
// Map {
|
|
554
|
+
// Map { 6: [6.1, 6.3], 4: [4.2] }
|
|
574
555
|
|
|
575
556
|
// The `property` iteratee shorthand.
|
|
576
557
|
groupByMap(['one', 'two', 'three'], 'length')
|
|
@@ -592,8 +573,8 @@ export declare function remove<T>(arr: T[], func: T[]): T[];
|
|
|
592
573
|
export declare function remove<T>(arr: T[], func: Iteratee<T>): T[];
|
|
593
574
|
/**
|
|
594
575
|
* Returns the index of `x` in a **sorted** array if found, in `O(log n)` using binary search.
|
|
595
|
-
* If the element is not found, returns
|
|
596
|
-
* @param arr The array
|
|
576
|
+
* If the element is not found, returns `-n - 1`, where `n` is the index to insert `x` at.
|
|
577
|
+
* @param arr The sorted array
|
|
597
578
|
* @param x The element to find
|
|
598
579
|
* @param lo The starting index
|
|
599
580
|
* @param hi The end index to search within
|
|
@@ -603,7 +584,7 @@ export declare function remove<T>(arr: T[], func: Iteratee<T>): T[];
|
|
|
603
584
|
export declare function binarySearch(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
|
|
604
585
|
/**
|
|
605
586
|
* Returns an insertion index which comes after any existing entries of `x` in a **sorted** array, using binary search.
|
|
606
|
-
* @param arr The array
|
|
587
|
+
* @param arr The sorted array
|
|
607
588
|
* @param x The element to find
|
|
608
589
|
* @param lo The starting index
|
|
609
590
|
* @param hi The end index to search within
|
|
@@ -613,7 +594,7 @@ export declare function binarySearch(arr: any[], x: any, lo?: number, hi?: any,
|
|
|
613
594
|
export declare function bisect(arr: any[], x: any, lo?: number, hi?: any, comp?: typeof compare): number;
|
|
614
595
|
/**
|
|
615
596
|
* Returns an insertion index which comes before any existing entries of `x` in a **sorted** array, using binary search.
|
|
616
|
-
* @param arr The array
|
|
597
|
+
* @param arr The sorted array
|
|
617
598
|
* @param x The element to find
|
|
618
599
|
* @param lo The starting index
|
|
619
600
|
* @param hi The end index to search within
|