es-toolkit 1.0.0-dev.24 → 1.0.2-canary.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/CHANGELOG.md +2 -2
- package/array.d.ts +1 -0
- package/dist/array/index.js +1 -1
- package/dist/array/uniqWith.d.ts +1 -1
- package/dist/index.js +1 -1
- package/esm/array/chunk.d.ts +24 -0
- package/esm/array/chunk.spec.d.ts +1 -0
- package/esm/array/difference.d.ts +23 -0
- package/esm/array/difference.spec.d.ts +1 -0
- package/esm/array/differenceBy.d.ts +26 -0
- package/esm/array/differenceBy.spec.d.ts +1 -0
- package/esm/array/differenceWith.d.ts +22 -0
- package/esm/array/differenceWith.spec.d.ts +1 -0
- package/esm/array/drop.d.ts +16 -0
- package/esm/array/drop.spec.d.ts +1 -0
- package/esm/array/dropRight.d.ts +16 -0
- package/esm/array/dropRight.spec.d.ts +1 -0
- package/esm/array/dropRightWhile.d.ts +18 -0
- package/esm/array/{dropRightWhile.mjs → dropRightWhile.js} +1 -1
- package/esm/array/dropRightWhile.spec.d.ts +1 -0
- package/esm/array/dropWhile.d.ts +18 -0
- package/esm/array/dropWhile.spec.d.ts +1 -0
- package/esm/array/groupBy.d.ts +31 -0
- package/esm/array/{groupBy.mjs → groupBy.js} +1 -1
- package/esm/array/groupBy.spec.d.ts +1 -0
- package/esm/array/index.d.ts +30 -0
- package/esm/array/index.js +30 -0
- package/esm/array/intersection.d.ts +18 -0
- package/esm/array/intersection.spec.d.ts +1 -0
- package/esm/array/intersectionBy.d.ts +21 -0
- package/esm/array/intersectionBy.spec.d.ts +1 -0
- package/esm/array/intersectionWith.d.ts +22 -0
- package/esm/array/intersectionWith.spec.d.ts +1 -0
- package/esm/array/partition.d.ts +22 -0
- package/esm/array/{partition.mjs → partition.js} +1 -1
- package/esm/array/partition.spec.d.ts +1 -0
- package/esm/array/sample.d.ts +14 -0
- package/esm/array/sample.spec.d.ts +1 -0
- package/esm/array/shuffle.d.ts +14 -0
- package/esm/array/shuffle.spec.d.ts +1 -0
- package/esm/array/take.d.ts +23 -0
- package/esm/array/take.spec.d.ts +1 -0
- package/esm/array/takeRight.d.ts +21 -0
- package/esm/array/takeRight.spec.d.ts +1 -0
- package/esm/array/takeRightWhile.d.ts +18 -0
- package/esm/array/takeRightWhile.spec.d.ts +1 -0
- package/esm/array/takeWhile.d.ts +19 -0
- package/esm/array/{takeWhile.mjs → takeWhile.js} +1 -1
- package/esm/array/takeWhile.spec.d.ts +1 -0
- package/esm/array/union.d.ts +17 -0
- package/esm/array/{union.mjs → union.js} +1 -1
- package/esm/array/union.spec.d.ts +1 -0
- package/esm/array/unionBy.d.ts +21 -0
- package/esm/array/{unionBy.mjs → unionBy.js} +1 -1
- package/esm/array/unionBy.spec.d.ts +1 -0
- package/esm/array/unionWith.d.ts +20 -0
- package/esm/array/{unionWith.mjs → unionWith.js} +1 -1
- package/esm/array/unionWith.spec.d.ts +1 -0
- package/esm/array/uniq.d.ts +15 -0
- package/esm/array/{uniq.mjs → uniq.js} +1 -1
- package/esm/array/uniq.spec.d.ts +1 -0
- package/esm/array/uniqBy.d.ts +12 -0
- package/esm/array/{uniqBy.mjs → uniqBy.js} +1 -1
- package/esm/array/uniqBy.spec.d.ts +1 -0
- package/esm/array/uniqWith.d.ts +12 -0
- package/esm/array/{uniqWith.mjs → uniqWith.js} +2 -2
- package/esm/array/uniqWith.spec.d.ts +1 -0
- package/esm/array/xor.d.ts +17 -0
- package/esm/array/{xor.mjs → xor.js} +3 -3
- package/esm/array/xor.spec.d.ts +1 -0
- package/esm/array/xorBy.d.ts +20 -0
- package/esm/array/{xorBy.mjs → xorBy.js} +3 -3
- package/esm/array/xorBy.spec.d.ts +1 -0
- package/esm/array/xorWith.d.ts +19 -0
- package/esm/array/{xorWith.mjs → xorWith.js} +3 -3
- package/esm/array/xorWith.spec.d.ts +1 -0
- package/esm/array/zip.d.ts +25 -0
- package/esm/array/{zip.mjs → zip.js} +1 -1
- package/esm/array/zip.spec.d.ts +1 -0
- package/esm/array/zipWith.d.ts +32 -0
- package/esm/array/{zipWith.mjs → zipWith.js} +1 -1
- package/esm/array/zipWith.spec.d.ts +1 -0
- package/esm/function/debounce.d.ts +24 -0
- package/esm/function/debounce.spec.d.ts +1 -0
- package/esm/function/index.d.ts +3 -0
- package/esm/function/index.js +3 -0
- package/esm/function/once.d.ts +17 -0
- package/esm/function/once.spec.d.ts +1 -0
- package/esm/function/throttle.d.ts +26 -0
- package/esm/function/throttle.spec.d.ts +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +45 -0
- package/esm/math/clamp.d.ts +19 -0
- package/esm/math/clamp.spec.d.ts +1 -0
- package/esm/math/index.d.ts +3 -0
- package/esm/math/index.js +3 -0
- package/esm/math/round.d.ts +16 -0
- package/esm/math/round.spec.d.ts +1 -0
- package/esm/math/sum.d.ts +14 -0
- package/esm/math/{sum.mjs → sum.js} +1 -1
- package/esm/math/sum.spec.d.ts +1 -0
- package/esm/object/index.d.ts +4 -0
- package/esm/object/index.js +4 -0
- package/esm/object/omit.d.ts +16 -0
- package/esm/object/{omit.mjs → omit.js} +1 -1
- package/esm/object/omit.spec.d.ts +1 -0
- package/esm/object/omitBy.d.ts +19 -0
- package/esm/object/{omitBy.mjs → omitBy.js} +1 -1
- package/esm/object/omitBy.spec.d.ts +1 -0
- package/esm/object/pick.d.ts +16 -0
- package/esm/object/{pick.mjs → pick.js} +1 -1
- package/esm/object/pick.spec.d.ts +1 -0
- package/esm/object/pickBy.d.ts +19 -0
- package/esm/object/{pickBy.mjs → pickBy.js} +1 -1
- package/esm/object/pickBy.spec.d.ts +1 -0
- package/esm/package.json +1 -0
- package/esm/predicate/index.d.ts +4 -0
- package/esm/predicate/index.js +4 -0
- package/esm/predicate/isNil.d.ts +20 -0
- package/esm/predicate/isNil.spec.d.ts +1 -0
- package/esm/predicate/isNotNil.d.ts +16 -0
- package/esm/predicate/isNotNil.spec.d.ts +1 -0
- package/esm/predicate/isNull.d.ts +21 -0
- package/esm/predicate/isNull.spec.d.ts +1 -0
- package/esm/predicate/isUndefined.d.ts +21 -0
- package/esm/predicate/isUndefined.spec.d.ts +1 -0
- package/esm/promise/delay.d.ts +19 -0
- package/esm/promise/delay.spec.d.ts +1 -0
- package/esm/promise/index.d.ts +1 -0
- package/esm/promise/index.js +1 -0
- package/function.d.ts +1 -0
- package/math.d.ts +1 -0
- package/object.d.ts +1 -0
- package/package.json +18 -17
- package/predicate.d.ts +1 -0
- package/promise.d.ts +1 -0
- package/esm/array/index.mjs +0 -30
- package/esm/function/index.mjs +0 -3
- package/esm/index.mjs +0 -45
- package/esm/math/index.mjs +0 -3
- package/esm/object/index.mjs +0 -4
- package/esm/predicate/index.mjs +0 -4
- package/esm/promise/index.mjs +0 -1
- /package/esm/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
- /package/esm/array/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
- /package/esm/array/{chunk.mjs → chunk.js} +0 -0
- /package/esm/array/{difference.mjs → difference.js} +0 -0
- /package/esm/array/{differenceBy.mjs → differenceBy.js} +0 -0
- /package/esm/array/{differenceWith.mjs → differenceWith.js} +0 -0
- /package/esm/array/{drop.mjs → drop.js} +0 -0
- /package/esm/array/{dropRight.mjs → dropRight.js} +0 -0
- /package/esm/array/{dropWhile.mjs → dropWhile.js} +0 -0
- /package/esm/array/{intersection.mjs → intersection.js} +0 -0
- /package/esm/array/{intersectionBy.mjs → intersectionBy.js} +0 -0
- /package/esm/array/{intersectionWith.mjs → intersectionWith.js} +0 -0
- /package/esm/array/{sample.mjs → sample.js} +0 -0
- /package/esm/array/{shuffle.mjs → shuffle.js} +0 -0
- /package/esm/array/{take.mjs → take.js} +0 -0
- /package/esm/array/{takeRight.mjs → takeRight.js} +0 -0
- /package/esm/array/{takeRightWhile.mjs → takeRightWhile.js} +0 -0
- /package/esm/function/{debounce.mjs → debounce.js} +0 -0
- /package/esm/function/{once.mjs → once.js} +0 -0
- /package/esm/function/{throttle.mjs → throttle.js} +0 -0
- /package/esm/math/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
- /package/esm/math/{clamp.mjs → clamp.js} +0 -0
- /package/esm/math/{round.mjs → round.js} +0 -0
- /package/esm/object/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
- /package/esm/predicate/{isNil.mjs → isNil.js} +0 -0
- /package/esm/predicate/{isNotNil.mjs → isNotNil.js} +0 -0
- /package/esm/predicate/{isNull.mjs → isNull.js} +0 -0
- /package/esm/predicate/{isUndefined.mjs → isUndefined.js} +0 -0
- /package/esm/promise/{delay.mjs → delay.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
|
|
3
|
+
*
|
|
4
|
+
* @param {T[]} arr1 - The first array.
|
|
5
|
+
* @param {T[]} arr2 - The second array.
|
|
6
|
+
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
|
|
7
|
+
* @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Custom mapping function for numbers (modulo comparison)
|
|
11
|
+
* const moduloMapper = (x) => x % 3;
|
|
12
|
+
* unionBy([1, 2, 3], [4, 5, 6], moduloMapper);
|
|
13
|
+
* // Returns [1, 2, 3]
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Custom mapping function for objects with an 'id' property
|
|
17
|
+
* const idMapper = (obj) => obj.id;
|
|
18
|
+
* unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
|
|
19
|
+
* // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
20
|
+
*/
|
|
21
|
+
export declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an array of unique values from two given arrays based on a custom equality function.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two arrays and a custom equality function, merges the arrays, and returns
|
|
5
|
+
* a new array containing only the unique values as determined by the custom equality function.
|
|
6
|
+
*
|
|
7
|
+
* @param {T[]} arr1 - The first array to merge and filter for unique values.
|
|
8
|
+
* @param {T[]} arr2 - The second array to merge and filter for unique values.
|
|
9
|
+
* @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
|
|
10
|
+
* It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.
|
|
11
|
+
* @returns {T[]} A new array of unique values based on the custom equality function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const array1 = [{ id: 1 }, { id: 2 }];
|
|
15
|
+
* const array2 = [{ id: 2 }, { id: 3 }];
|
|
16
|
+
* const areItemsEqual = (a, b) => a.id === b.id;
|
|
17
|
+
* const result = unionWith(array1, array2, areItemsEqual);
|
|
18
|
+
* // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
|
|
19
|
+
*/
|
|
20
|
+
export declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a duplicate-free version of an array.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and returns a new array containing only the unique values
|
|
5
|
+
* from the original array, preserving the order of first occurrence.
|
|
6
|
+
*
|
|
7
|
+
* @param {T[]} arr - The array to process.
|
|
8
|
+
* @returns {T[]} A new array with only unique values from the original array.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* * const array = [1, 2, 2, 3, 4, 4, 5];
|
|
12
|
+
* const result = uniq(array);
|
|
13
|
+
* // result will be [1, 2, 3, 4, 5]
|
|
14
|
+
*/
|
|
15
|
+
export declare function uniq<T>(arr: T[]): T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a duplicate-free version of an array.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
|
|
3
|
+
*
|
|
4
|
+
* It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
|
9
|
+
* // [1.2, 2.1, 3.3, 5.7, 7.19]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { uniqWith } from './uniqWith.
|
|
1
|
+
import { uniqWith } from './uniqWith.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
|
|
3
|
+
*
|
|
4
|
+
* It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
|
|
9
|
+
* // [1, 2, 3, 5, 7]
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
|
|
@@ -7,7 +7,7 @@ import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virt
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
|
-
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
|
|
10
|
+
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
|
|
11
11
|
* // [1, 2, 3, 5, 7]
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
|
|
3
|
+
* which are in either of the arrays, but not in their intersection.
|
|
4
|
+
*
|
|
5
|
+
* @param {T[]} arr1 - The first array.
|
|
6
|
+
* @param {T[]} arr2 - The second array.
|
|
7
|
+
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Returns [1, 2, 5, 6]
|
|
11
|
+
* xor([1, 2, 3, 4], [3, 4, 5, 6]);
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Returns ['a', 'c']
|
|
15
|
+
* xor(['a', 'b'], ['b', 'c']);
|
|
16
|
+
*/
|
|
17
|
+
export declare function xor<T>(arr1: T[], arr2: T[]): T[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { difference } from './difference.
|
|
2
|
-
import { intersection } from './intersection.
|
|
3
|
-
import { union } from './union.
|
|
1
|
+
import { difference } from './difference.js';
|
|
2
|
+
import { intersection } from './intersection.js';
|
|
3
|
+
import { union } from './union.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the symmetric difference between two arrays using a custom mapping function.
|
|
3
|
+
* The symmetric difference is the set of elements which are in either of the arrays,
|
|
4
|
+
* but not in their intersection, determined by the result of the mapping function.
|
|
5
|
+
*
|
|
6
|
+
* @template T - Type of elements in the input arrays.
|
|
7
|
+
* @template U - Type of the values returned by the mapping function.
|
|
8
|
+
*
|
|
9
|
+
* @param {T[]} arr1 - The first array.
|
|
10
|
+
* @param {T[]} arr2 - The second array.
|
|
11
|
+
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
|
|
12
|
+
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Custom mapping function for objects with an 'id' property
|
|
16
|
+
* const idMapper = obj => obj.id;
|
|
17
|
+
* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
|
|
18
|
+
* // Returns [{ id: 1 }, { id: 3 }]
|
|
19
|
+
*/
|
|
20
|
+
export declare function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { differenceBy } from './differenceBy.
|
|
2
|
-
import { intersectionBy } from './intersectionBy.
|
|
3
|
-
import { unionBy } from './unionBy.
|
|
1
|
+
import { differenceBy } from './differenceBy.js';
|
|
2
|
+
import { intersectionBy } from './intersectionBy.js';
|
|
3
|
+
import { unionBy } from './unionBy.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Computes the symmetric difference between two arrays using a custom mapping function.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the symmetric difference between two arrays using a custom equality function.
|
|
3
|
+
* The symmetric difference is the set of elements which are in either of the arrays,
|
|
4
|
+
* but not in their intersection.
|
|
5
|
+
*
|
|
6
|
+
* @template T - Type of elements in the input arrays.
|
|
7
|
+
*
|
|
8
|
+
* @param {T[]} arr1 - The first array.
|
|
9
|
+
* @param {T[]} arr2 - The second array.
|
|
10
|
+
* @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
|
|
11
|
+
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Custom equality function for objects with an 'id' property
|
|
15
|
+
* const areObjectsEqual = (a, b) => a.id === b.id;
|
|
16
|
+
* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
|
|
17
|
+
* // Returns [{ id: 1 }, { id: 3 }]
|
|
18
|
+
*/
|
|
19
|
+
export declare function xorWith<T>(arr1: T[], arr2: T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { differenceWith } from './differenceWith.
|
|
2
|
-
import { intersectionWith } from './intersectionWith.
|
|
3
|
-
import { unionWith } from './unionWith.
|
|
1
|
+
import { differenceWith } from './differenceWith.js';
|
|
2
|
+
import { intersectionWith } from './intersectionWith.js';
|
|
3
|
+
import { unionWith } from './unionWith.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Computes the symmetric difference between two arrays using a custom equality function.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines multiple arrays into a single array of tuples.
|
|
3
|
+
*
|
|
4
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
5
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
6
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
7
|
+
* with undefined values for missing elements.
|
|
8
|
+
*
|
|
9
|
+
* @param {...T[][]} arrs - The arrays to zip together.
|
|
10
|
+
* @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const arr1 = [1, 2, 3];
|
|
14
|
+
* const arr2 = ['a', 'b', 'c'];
|
|
15
|
+
* const result = zip(arr1, arr2);
|
|
16
|
+
* // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
|
|
17
|
+
*
|
|
18
|
+
* const arr3 = [true, false];
|
|
19
|
+
* const result2 = zip(arr1, arr2, arr3);
|
|
20
|
+
* // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
|
|
21
|
+
*/
|
|
22
|
+
export declare function zip<T>(arr1: T[]): [T][];
|
|
23
|
+
export declare function zip<T, U>(arr1: T[], arr2: U[]): [T, U][];
|
|
24
|
+
export declare function zip<T, U, V>(arr1: T[], arr2: U[], arr3: V[]): [T, U, V][];
|
|
25
|
+
export declare function zip<T, U, V, W>(arr1: T[], arr2: U[], arr3: V[], arr4: W[]): [T, U, V, W][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConsumableArray as _toConsumableArray, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { toConsumableArray as _toConsumableArray, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Combines multiple arrays into a single array of tuples.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines multiple arrays into a single array using a custom combiner function.
|
|
3
|
+
*
|
|
4
|
+
* This function takes multiple arrays and a combiner function, and returns a new array where each element
|
|
5
|
+
* is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
6
|
+
*
|
|
7
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
8
|
+
* @param {U[]} [arr2] - The second array to zip (optional).
|
|
9
|
+
* @param {V[]} [arr3] - The third array to zip (optional).
|
|
10
|
+
* @param {W[]} [arr4] - The fourth array to zip (optional).
|
|
11
|
+
* @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
12
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Example usage with two arrays:
|
|
16
|
+
* const arr1 = [1, 2, 3];
|
|
17
|
+
* const arr2 = [4, 5, 6];
|
|
18
|
+
* const result = zipWith(arr1, arr2, (a, b) => a + b);
|
|
19
|
+
* // result will be [5, 7, 9]
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Example usage with three arrays:
|
|
23
|
+
* const arr1 = [1, 2];
|
|
24
|
+
* const arr2 = [3, 4];
|
|
25
|
+
* const arr3 = [5, 6];
|
|
26
|
+
* const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
|
|
27
|
+
* // result will be [`135`, `246`]
|
|
28
|
+
*/
|
|
29
|
+
export declare function zipWith<T, R>(arr1: T[], combine: (item: T) => R): R[];
|
|
30
|
+
export declare function zipWith<T, U, R>(arr1: T[], arr2: U[], combine: (item1: T, item2: U) => R): R[];
|
|
31
|
+
export declare function zipWith<T, U, V, R>(arr1: T[], arr2: U[], arr3: V[], combine: (item1: T, item2: U, item3: V) => R): R[];
|
|
32
|
+
export declare function zipWith<T, U, V, W, R>(arr1: T[], arr2: U[], arr3: V[], arr4: W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Combines multiple arrays into a single array using a custom combiner function.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
3
|
+
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
4
|
+
* method to cancel any pending execution.
|
|
5
|
+
*
|
|
6
|
+
* @param {() => void} func - The function to debounce.
|
|
7
|
+
* @param {number} debounceMs - The number of milliseconds to delay.
|
|
8
|
+
* @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const debouncedFunction = debounce(() => {
|
|
12
|
+
* console.log('Function executed');
|
|
13
|
+
* }, 1000);
|
|
14
|
+
*
|
|
15
|
+
* // Will log 'Function executed' after 1 second if not called again in that time
|
|
16
|
+
* debouncedFunction();
|
|
17
|
+
*
|
|
18
|
+
* // Will not log anything as the previous call is canceled
|
|
19
|
+
* debouncedFunction.cancel();
|
|
20
|
+
*/
|
|
21
|
+
export declare function debounce(func: () => void, debounceMs: number): {
|
|
22
|
+
(): void;
|
|
23
|
+
cancel: () => void;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that is restricted to invoking the provided function `func` once.
|
|
3
|
+
* Repeated calls to the function will return the value from the first invocation.
|
|
4
|
+
*
|
|
5
|
+
* @param {F} func - The function to restrict.
|
|
6
|
+
* @returns {F} A new function that invokes `func` once and caches the result.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const initialize = once(() => {
|
|
10
|
+
* console.log('Initialized!');
|
|
11
|
+
* return true;
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* initialize(); // Logs: 'Initialized!' and returns true
|
|
15
|
+
* initialize(); // Returns true without logging
|
|
16
|
+
*/
|
|
17
|
+
export declare function once<F extends () => any>(func: F): F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a throttled function that only invokes the provided function at most once
|
|
3
|
+
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
4
|
+
* within the wait time will not trigger the execution of the original function.
|
|
5
|
+
*
|
|
6
|
+
* @param {() => void} func - The function to throttle.
|
|
7
|
+
* @param {number} throttleMs - The number of milliseconds to throttle executions to.
|
|
8
|
+
* @returns {() => void} A new throttled function.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const throttledFunction = throttle(() => {
|
|
12
|
+
* console.log('Function executed');
|
|
13
|
+
* }, 1000);
|
|
14
|
+
*
|
|
15
|
+
* // Will log 'Function executed' immediately
|
|
16
|
+
* throttledFunction();
|
|
17
|
+
*
|
|
18
|
+
* // Will not log anything as it is within the throttle time
|
|
19
|
+
* throttledFunction();
|
|
20
|
+
*
|
|
21
|
+
* // After 1 second
|
|
22
|
+
* setTimeout(() => {
|
|
23
|
+
* throttledFunction(); // Will log 'Function executed'
|
|
24
|
+
* }, 1000);
|
|
25
|
+
*/
|
|
26
|
+
export declare function throttle(func: () => void, throttleMs: number): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { chunk } from './array/chunk.js';
|
|
2
|
+
export { difference } from './array/difference.js';
|
|
3
|
+
export { differenceBy } from './array/differenceBy.js';
|
|
4
|
+
export { differenceWith } from './array/differenceWith.js';
|
|
5
|
+
export { drop } from './array/drop.js';
|
|
6
|
+
export { dropRight } from './array/dropRight.js';
|
|
7
|
+
export { dropRightWhile } from './array/dropRightWhile.js';
|
|
8
|
+
export { dropWhile } from './array/dropWhile.js';
|
|
9
|
+
export { groupBy } from './array/groupBy.js';
|
|
10
|
+
export { intersection } from './array/intersection.js';
|
|
11
|
+
export { intersectionBy } from './array/intersectionBy.js';
|
|
12
|
+
export { intersectionWith } from './array/intersectionWith.js';
|
|
13
|
+
export { partition } from './array/partition.js';
|
|
14
|
+
export { sample } from './array/sample.js';
|
|
15
|
+
export { shuffle } from './array/shuffle.js';
|
|
16
|
+
export { take } from './array/take.js';
|
|
17
|
+
export { takeRight } from './array/takeRight.js';
|
|
18
|
+
export { takeRightWhile } from './array/takeRightWhile.js';
|
|
19
|
+
export { takeWhile } from './array/takeWhile.js';
|
|
20
|
+
export { union } from './array/union.js';
|
|
21
|
+
export { unionBy } from './array/unionBy.js';
|
|
22
|
+
export { unionWith } from './array/unionWith.js';
|
|
23
|
+
export { uniq } from './array/uniq.js';
|
|
24
|
+
export { uniqBy } from './array/uniqBy.js';
|
|
25
|
+
export { uniqWith } from './array/uniqWith.js';
|
|
26
|
+
export { xor } from './array/xor.js';
|
|
27
|
+
export { xorBy } from './array/xorBy.js';
|
|
28
|
+
export { xorWith } from './array/xorWith.js';
|
|
29
|
+
export { zip } from './array/zip.js';
|
|
30
|
+
export { zipWith } from './array/zipWith.js';
|
|
31
|
+
export { debounce } from './function/debounce.js';
|
|
32
|
+
export { once } from './function/once.js';
|
|
33
|
+
export { throttle } from './function/throttle.js';
|
|
34
|
+
export { clamp } from './math/clamp.js';
|
|
35
|
+
export { round } from './math/round.js';
|
|
36
|
+
export { sum } from './math/sum.js';
|
|
37
|
+
export { omit } from './object/omit.js';
|
|
38
|
+
export { omitBy } from './object/omitBy.js';
|
|
39
|
+
export { pick } from './object/pick.js';
|
|
40
|
+
export { pickBy } from './object/pickBy.js';
|
|
41
|
+
export { isNil } from './predicate/isNil.js';
|
|
42
|
+
export { isNotNil } from './predicate/isNotNil.js';
|
|
43
|
+
export { isNull } from './predicate/isNull.js';
|
|
44
|
+
export { isUndefined } from './predicate/isUndefined.js';
|
|
45
|
+
export { delay } from './promise/delay.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a number within the inclusive lower and upper bounds.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a number and two bounds, and returns the number clamped within the specified bounds.
|
|
5
|
+
* If only one bound is provided, it returns the minimum of the value and the bound.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The number to clamp.
|
|
8
|
+
* @param {number} minimum - The minimum bound to clamp the number.
|
|
9
|
+
* @param {number} maximum - The maximum bound to clamp the number.
|
|
10
|
+
* @returns {number} The clamped number within the specified bounds.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
|
|
14
|
+
* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
|
|
15
|
+
* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
|
|
16
|
+
* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
|
|
17
|
+
*/
|
|
18
|
+
export declare function clamp(value: number, maximum: number): number;
|
|
19
|
+
export declare function clamp(value: number, minimum: number, maximum: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rounds a number to a specified precision.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a number and an optional precision value, and returns the number rounded
|
|
5
|
+
* to the specified number of decimal places.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The number to round.
|
|
8
|
+
* @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
|
|
9
|
+
* @returns {number} The rounded number.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* * const result1 = round(1.2345); // result1 will be 1
|
|
13
|
+
* const result2 = round(1.2345, 2); // result2 will be 1.23
|
|
14
|
+
* const result3 = round(1.2345, 3); // result3 will be 1.235
|
|
15
|
+
*/
|
|
16
|
+
export declare function round(value: number, precision?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the sum of an array of numbers.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array of numbers and returns the sum of all the elements in the array.
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]} nums - An array of numbers to be summed.
|
|
7
|
+
* @returns {number} The sum of all the numbers in the array.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* * const numbers = [1, 2, 3, 4, 5];
|
|
11
|
+
* const result = sum(numbers);
|
|
12
|
+
* // result will be 15
|
|
13
|
+
*/
|
|
14
|
+
export declare function sum(nums: number[]): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Calculates the sum of an array of numbers.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object with specified keys omitted.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an object and an array of keys, and returns a new object that
|
|
5
|
+
* excludes the properties corresponding to the specified keys.
|
|
6
|
+
*
|
|
7
|
+
* @param {T} obj - The object to omit keys from.
|
|
8
|
+
* @param {K[]} keys - An array of keys to be omitted from the object.
|
|
9
|
+
* @returns {Omit<T, K>} A new object with the specified keys omitted.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* * const obj = { a: 1, b: 2, c: 3 };
|
|
13
|
+
* const result = omit(obj, ['b', 'c']);
|
|
14
|
+
* // result will be { a: 1 }
|
|
15
|
+
*/
|
|
16
|
+
export declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.
|
|
1
|
+
import { objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new object with specified keys omitted.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an object and a predicate function, and returns a new object that
|
|
5
|
+
* includes only the properties for which the predicate function returns false.
|
|
6
|
+
*
|
|
7
|
+
* @param {T} obj - The object to omit properties from.
|
|
8
|
+
* @param {(value: T[string], key: string) => boolean} shouldOmit - A predicate function that determines
|
|
9
|
+
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
|
10
|
+
* if the property should be omitted, and `false` otherwise.
|
|
11
|
+
* @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const obj = { a: 1, b: 'omit', c: 3 };
|
|
15
|
+
* const shouldOmit = (key, value) => typeof value === 'string';
|
|
16
|
+
* const result = omitBy(obj, shouldOmit);
|
|
17
|
+
* // result will be { a: 1, c: 3 }
|
|
18
|
+
*/
|
|
19
|
+
export declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: string) => boolean): Partial<T>;
|