es-toolkit 0.0.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.
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +10 -0
- package/.yarn/sdks/eslint/bin/eslint.js +20 -0
- package/.yarn/sdks/eslint/lib/api.js +20 -0
- package/.yarn/sdks/eslint/lib/unsupported-api.js +20 -0
- package/.yarn/sdks/eslint/package.json +14 -0
- package/.yarn/sdks/integrations.yml +5 -0
- package/.yarn/sdks/prettier/bin/prettier.cjs +20 -0
- package/.yarn/sdks/prettier/index.cjs +20 -0
- package/.yarn/sdks/prettier/package.json +7 -0
- package/.yarn/sdks/typescript/bin/tsc +20 -0
- package/.yarn/sdks/typescript/bin/tsserver +20 -0
- package/.yarn/sdks/typescript/lib/tsc.js +20 -0
- package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
- package/.yarn/sdks/typescript/lib/typescript.js +20 -0
- package/.yarn/sdks/typescript/package.json +10 -0
- package/babel.config.js +6 -0
- package/coverage/.tmp/coverage-0.json +1 -0
- package/coverage/.tmp/coverage-1.json +1 -0
- package/coverage/.tmp/coverage-10.json +1 -0
- package/coverage/.tmp/coverage-11.json +1 -0
- package/coverage/.tmp/coverage-12.json +1 -0
- package/coverage/.tmp/coverage-13.json +1 -0
- package/coverage/.tmp/coverage-14.json +1 -0
- package/coverage/.tmp/coverage-15.json +1 -0
- package/coverage/.tmp/coverage-16.json +1 -0
- package/coverage/.tmp/coverage-17.json +1 -0
- package/coverage/.tmp/coverage-18.json +1 -0
- package/coverage/.tmp/coverage-19.json +1 -0
- package/coverage/.tmp/coverage-2.json +1 -0
- package/coverage/.tmp/coverage-20.json +1 -0
- package/coverage/.tmp/coverage-21.json +1 -0
- package/coverage/.tmp/coverage-22.json +1 -0
- package/coverage/.tmp/coverage-23.json +1 -0
- package/coverage/.tmp/coverage-24.json +1 -0
- package/coverage/.tmp/coverage-25.json +1 -0
- package/coverage/.tmp/coverage-26.json +1 -0
- package/coverage/.tmp/coverage-27.json +1 -0
- package/coverage/.tmp/coverage-28.json +1 -0
- package/coverage/.tmp/coverage-29.json +1 -0
- package/coverage/.tmp/coverage-3.json +1 -0
- package/coverage/.tmp/coverage-30.json +1 -0
- package/coverage/.tmp/coverage-4.json +1 -0
- package/coverage/.tmp/coverage-5.json +1 -0
- package/coverage/.tmp/coverage-6.json +1 -0
- package/coverage/.tmp/coverage-7.json +1 -0
- package/coverage/.tmp/coverage-8.json +1 -0
- package/coverage/.tmp/coverage-9.json +1 -0
- package/dist/array/chunk.d.ts +8 -0
- package/dist/array/chunk.spec.d.ts +1 -0
- package/dist/array/difference.d.ts +7 -0
- package/dist/array/difference.spec.d.ts +1 -0
- package/dist/array/differenceBy.d.ts +8 -0
- package/dist/array/differenceBy.spec.d.ts +1 -0
- package/dist/array/differenceWith.d.ts +8 -0
- package/dist/array/differenceWith.spec.d.ts +1 -0
- package/dist/array/drop.d.ts +7 -0
- package/dist/array/drop.spec.d.ts +1 -0
- package/dist/array/dropRight.d.ts +7 -0
- package/dist/array/dropRight.spec.d.ts +1 -0
- package/dist/array/dropRightWhile.d.ts +7 -0
- package/dist/array/dropRightWhile.spec.d.ts +1 -0
- package/dist/array/dropWhile.d.ts +7 -0
- package/dist/array/dropWhile.spec.d.ts +1 -0
- package/dist/array/groupBy.d.ts +1 -0
- package/dist/array/index.d.ts +30 -0
- package/dist/array/index.js +778 -0
- package/dist/array/intersection.d.ts +11 -0
- package/dist/array/intersection.spec.d.ts +1 -0
- package/dist/array/intersectionBy.d.ts +12 -0
- package/dist/array/intersectionBy.spec.d.ts +1 -0
- package/dist/array/intersectionWith.d.ts +12 -0
- package/dist/array/intersectionWith.spec.d.ts +1 -0
- package/dist/array/partition.d.ts +8 -0
- package/dist/array/partition.spec.d.ts +1 -0
- package/dist/array/sample.d.ts +7 -0
- package/dist/array/sample.spec.d.ts +1 -0
- package/dist/array/shuffle.d.ts +7 -0
- package/dist/array/shuffle.spec.d.ts +1 -0
- package/dist/array/take.d.ts +23 -0
- package/dist/array/take.spec.d.ts +1 -0
- package/dist/array/takeRight.d.ts +23 -0
- package/dist/array/takeRight.spec.d.ts +1 -0
- package/dist/array/takeRightWhile.d.ts +18 -0
- package/dist/array/takeRightWhile.spec.d.ts +1 -0
- package/dist/array/takeWhile.d.ts +19 -0
- package/dist/array/takeWhile.spec.d.ts +1 -0
- package/dist/array/union.d.ts +10 -0
- package/dist/array/union.spec.d.ts +1 -0
- package/dist/array/unionBy.d.ts +24 -0
- package/dist/array/unionBy.spec.d.ts +1 -0
- package/dist/array/unionWith.d.ts +14 -0
- package/dist/array/unionWith.spec.d.ts +1 -0
- package/dist/array/uniq.d.ts +14 -0
- package/dist/array/uniq.spec.d.ts +1 -0
- package/dist/array/uniqBy.d.ts +12 -0
- package/dist/array/uniqBy.spec.d.ts +1 -0
- package/dist/array/uniqWith.d.ts +12 -0
- package/dist/array/uniqWith.spec.d.ts +1 -0
- package/dist/array/xor.d.ts +19 -0
- package/dist/array/xor.spec.d.ts +1 -0
- package/dist/array/xorBy.d.ts +20 -0
- package/dist/array/xorBy.spec.d.ts +1 -0
- package/dist/array/xorWith.d.ts +19 -0
- package/dist/array/xorWith.spec.d.ts +1 -0
- package/dist/array/zip.d.ts +13 -0
- package/dist/array/zip.spec.d.ts +1 -0
- package/dist/array/zipWith.d.ts +9 -0
- package/dist/array/zipWith.spec.d.ts +1 -0
- package/dist/function/debounce.d.ts +24 -0
- package/dist/function/debounce.spec.d.ts +1 -0
- package/dist/function/index.d.ts +3 -0
- package/dist/function/index.js +113 -0
- package/dist/function/once.d.ts +18 -0
- package/dist/function/once.spec.d.ts +1 -0
- package/dist/function/throttle.d.ts +26 -0
- package/dist/function/throttle.spec.d.ts +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1111 -0
- package/dist/math/clamp.d.ts +11 -0
- package/dist/math/clamp.spec.d.ts +1 -0
- package/dist/math/index.d.ts +3 -0
- package/dist/math/index.js +63 -0
- package/dist/math/round.d.ts +13 -0
- package/dist/math/round.spec.d.ts +1 -0
- package/dist/math/sum.d.ts +13 -0
- package/dist/math/sum.spec.d.ts +1 -0
- package/dist/object/index.d.ts +4 -0
- package/dist/object/index.js +176 -0
- package/dist/object/omit.d.ts +7 -0
- package/dist/object/omit.spec.d.ts +1 -0
- package/dist/object/omitBy.d.ts +1 -0
- package/dist/object/pick.d.ts +7 -0
- package/dist/object/pick.spec.d.ts +1 -0
- package/dist/object/pickBy.d.ts +1 -0
- package/dist/predicate/index.d.ts +4 -0
- package/dist/predicate/index.js +50 -0
- package/dist/predicate/isNil.d.ts +6 -0
- package/dist/predicate/isNil.spec.d.ts +1 -0
- package/dist/predicate/isNotNil.d.ts +12 -0
- package/dist/predicate/isNotNil.spec.d.ts +1 -0
- package/dist/predicate/isNull.d.ts +6 -0
- package/dist/predicate/isNull.spec.d.ts +1 -0
- package/dist/predicate/isUndefined.d.ts +6 -0
- package/dist/predicate/isUndefined.spec.d.ts +1 -0
- package/dist/promise/delay.d.ts +6 -0
- package/dist/promise/delay.spec.d.ts +1 -0
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/index.js +16 -0
- package/esm/_virtual/_rollupPluginBabelHelpers.mjs +163 -0
- package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +114 -0
- package/esm/array/chunk.mjs +35 -0
- package/esm/array/difference.mjs +13 -0
- package/esm/array/differenceBy.mjs +17 -0
- package/esm/array/differenceWith.mjs +16 -0
- package/esm/array/drop.mjs +11 -0
- package/esm/array/dropRight.mjs +11 -0
- package/esm/array/dropRightWhile.mjs +15 -0
- package/esm/array/dropWhile.mjs +14 -0
- package/esm/array/groupBy.mjs +5 -0
- package/esm/array/index.mjs +30 -0
- package/esm/array/intersection.mjs +17 -0
- package/esm/array/intersectionBy.mjs +21 -0
- package/esm/array/intersectionWith.mjs +20 -0
- package/esm/array/partition.mjs +32 -0
- package/esm/array/sample.mjs +12 -0
- package/esm/array/shuffle.mjs +20 -0
- package/esm/array/take.mjs +27 -0
- package/esm/array/takeRight.mjs +30 -0
- package/esm/array/takeRightWhile.mjs +27 -0
- package/esm/array/takeWhile.mjs +41 -0
- package/esm/array/union.mjs +19 -0
- package/esm/array/unionBy.mjs +38 -0
- package/esm/array/unionWith.mjs +21 -0
- package/esm/array/uniq.mjs +18 -0
- package/esm/array/uniqBy.mjs +20 -0
- package/esm/array/uniqWith.mjs +39 -0
- package/esm/array/xor.mjs +27 -0
- package/esm/array/xorBy.mjs +30 -0
- package/esm/array/xorWith.mjs +29 -0
- package/esm/array/zip.mjs +40 -0
- package/esm/array/zipWith.mjs +31 -0
- package/esm/function/debounce.mjs +39 -0
- package/esm/function/index.mjs +3 -0
- package/esm/function/once.mjs +32 -0
- package/esm/function/throttle.mjs +38 -0
- package/esm/index.mjs +45 -0
- package/esm/math/clamp.mjs +18 -0
- package/esm/math/index.mjs +3 -0
- package/esm/math/round.mjs +19 -0
- package/esm/math/sum.mjs +22 -0
- package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +115 -0
- package/esm/object/index.mjs +4 -0
- package/esm/object/omit.mjs +26 -0
- package/esm/object/omitBy.mjs +5 -0
- package/esm/object/pick.mjs +26 -0
- package/esm/object/pickBy.mjs +5 -0
- package/esm/predicate/index.mjs +4 -0
- package/esm/predicate/isNil.mjs +10 -0
- package/esm/predicate/isNotNil.mjs +16 -0
- package/esm/predicate/isNull.mjs +10 -0
- package/esm/predicate/isUndefined.mjs +10 -0
- package/esm/promise/delay.mjs +12 -0
- package/esm/promise/index.mjs +1 -0
- package/package.json +94 -0
- package/rollup.config.js +5 -0
- package/src/array/chunk.spec.ts +27 -0
- package/src/array/chunk.ts +24 -0
- package/src/array/difference.spec.ts +10 -0
- package/src/array/difference.ts +11 -0
- package/src/array/differenceBy.spec.ts +9 -0
- package/src/array/differenceBy.ts +14 -0
- package/src/array/differenceWith.spec.ts +8 -0
- package/src/array/differenceWith.ts +14 -0
- package/src/array/drop.spec.ts +9 -0
- package/src/array/drop.ts +9 -0
- package/src/array/dropRight.spec.ts +9 -0
- package/src/array/dropRight.ts +9 -0
- package/src/array/dropRightWhile.spec.ts +16 -0
- package/src/array/dropRightWhile.ts +13 -0
- package/src/array/dropWhile.spec.ts +14 -0
- package/src/array/dropWhile.ts +10 -0
- package/src/array/groupBy.ts +3 -0
- package/src/array/index.ts +30 -0
- package/src/array/intersection.spec.ts +11 -0
- package/src/array/intersection.ts +15 -0
- package/src/array/intersectionBy.spec.ts +9 -0
- package/src/array/intersectionBy.ts +18 -0
- package/src/array/intersectionWith.spec.ts +9 -0
- package/src/array/intersectionWith.ts +18 -0
- package/src/array/partition.spec.ts +23 -0
- package/src/array/partition.ts +21 -0
- package/src/array/sample.spec.ts +11 -0
- package/src/array/sample.ts +10 -0
- package/src/array/shuffle.spec.ts +11 -0
- package/src/array/shuffle.ts +18 -0
- package/src/array/take.spec.ts +25 -0
- package/src/array/take.ts +25 -0
- package/src/array/takeRight.spec.ts +25 -0
- package/src/array/takeRight.ts +29 -0
- package/src/array/takeRightWhile.spec.ts +16 -0
- package/src/array/takeRightWhile.ts +26 -0
- package/src/array/takeWhile.spec.ts +34 -0
- package/src/array/takeWhile.ts +31 -0
- package/src/array/union.spec.ts +10 -0
- package/src/array/union.ts +14 -0
- package/src/array/unionBy.spec.ts +12 -0
- package/src/array/unionBy.ts +35 -0
- package/src/array/unionWith.spec.ts +23 -0
- package/src/array/unionWith.ts +18 -0
- package/src/array/uniq.spec.ts +8 -0
- package/src/array/uniq.ts +16 -0
- package/src/array/uniqBy.spec.ts +8 -0
- package/src/array/uniqBy.ts +17 -0
- package/src/array/uniqWith.spec.ts +16 -0
- package/src/array/uniqWith.ts +29 -0
- package/src/array/xor.spec.ts +13 -0
- package/src/array/xor.ts +25 -0
- package/src/array/xorBy.spec.ts +16 -0
- package/src/array/xorBy.ts +29 -0
- package/src/array/xorWith.spec.ts +16 -0
- package/src/array/xorWith.ts +28 -0
- package/src/array/zip.spec.ts +14 -0
- package/src/array/zip.ts +34 -0
- package/src/array/zipWith.spec.ts +13 -0
- package/src/array/zipWith.ts +23 -0
- package/src/function/debounce.spec.ts +76 -0
- package/src/function/debounce.ts +42 -0
- package/src/function/index.ts +3 -0
- package/src/function/once.spec.ts +31 -0
- package/src/function/once.ts +34 -0
- package/src/function/throttle.spec.ts +32 -0
- package/src/function/throttle.ts +39 -0
- package/src/index.ts +6 -0
- package/src/math/clamp.spec.ts +18 -0
- package/src/math/clamp.ts +17 -0
- package/src/math/index.ts +3 -0
- package/src/math/round.spec.ts +53 -0
- package/src/math/round.ts +16 -0
- package/src/math/sum.spec.ts +29 -0
- package/src/math/sum.ts +17 -0
- package/src/object/index.ts +4 -0
- package/src/object/omit.spec.ts +10 -0
- package/src/object/omit.ts +15 -0
- package/src/object/omitBy.ts +3 -0
- package/src/object/pick.spec.ts +10 -0
- package/src/object/pick.ts +15 -0
- package/src/object/pickBy.ts +3 -0
- package/src/predicate/index.ts +4 -0
- package/src/predicate/isNil.spec.ts +23 -0
- package/src/predicate/isNil.ts +8 -0
- package/src/predicate/isNotNil.spec.ts +29 -0
- package/src/predicate/isNotNil.ts +14 -0
- package/src/predicate/isNull.spec.ts +23 -0
- package/src/predicate/isNull.ts +8 -0
- package/src/predicate/isUndefined.spec.ts +23 -0
- package/src/predicate/isUndefined.ts +8 -0
- package/src/promise/delay.spec.ts +13 -0
- package/src/promise/delay.ts +10 -0
- package/src/promise/index.ts +1 -0
- package/tsconfig.json +12 -0
- package/vitest.config.mts +13 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { uniqWith } from './uniqWith.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
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.
|
|
5
|
+
*
|
|
6
|
+
* It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
|
|
11
|
+
* // [1.2, 2.1, 3.3, 5.7, 7.19]
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function uniqBy(arr, converter) {
|
|
15
|
+
return uniqWith(arr, function (item1, item2) {
|
|
16
|
+
return converter(item1) === converter(item2);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { uniqBy };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
|
|
5
|
+
*
|
|
6
|
+
* 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.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
|
|
11
|
+
* // [1, 2, 3, 5, 7]
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function uniqWith(arr, areItemsEqual) {
|
|
15
|
+
var result = [];
|
|
16
|
+
var _iterator = _createForOfIteratorHelper(arr),
|
|
17
|
+
_step;
|
|
18
|
+
try {
|
|
19
|
+
var _loop = function _loop() {
|
|
20
|
+
var item = _step.value;
|
|
21
|
+
var isUniq = result.every(function (v) {
|
|
22
|
+
return !areItemsEqual(v, item);
|
|
23
|
+
});
|
|
24
|
+
if (isUniq) {
|
|
25
|
+
result.push(item);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
29
|
+
_loop();
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { uniqWith };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { difference } from './difference.mjs';
|
|
2
|
+
import { intersection } from './intersection.mjs';
|
|
3
|
+
import { union } from './union.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
|
|
7
|
+
* which are in either of the arrays, but not in their intersection.
|
|
8
|
+
*
|
|
9
|
+
* @template T - Type of elements in the input arrays.
|
|
10
|
+
*
|
|
11
|
+
* @param {T[]} arr1 - The first array.
|
|
12
|
+
* @param {T[]} arr2 - The second array.
|
|
13
|
+
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Returns [1, 2, 5, 6]
|
|
17
|
+
* xor([1, 2, 3, 4], [3, 4, 5, 6]);
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Returns ['a', 'c']
|
|
21
|
+
* xor(['a', 'b'], ['b', 'c']);
|
|
22
|
+
*/
|
|
23
|
+
function xor(arr1, arr2) {
|
|
24
|
+
return difference(union(arr1, arr2), intersection(arr1, arr2));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { xor };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { differenceBy } from './differenceBy.mjs';
|
|
2
|
+
import { intersectionBy } from './intersectionBy.mjs';
|
|
3
|
+
import { unionBy } from './unionBy.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Computes the symmetric difference between two arrays using a custom mapping function.
|
|
7
|
+
* The symmetric difference is the set of elements which are in either of the arrays,
|
|
8
|
+
* but not in their intersection, determined by the result of the mapping function.
|
|
9
|
+
*
|
|
10
|
+
* @template T - Type of elements in the input arrays.
|
|
11
|
+
* @template U - Type of the values returned by the mapping function.
|
|
12
|
+
*
|
|
13
|
+
* @param {T[]} arr1 - The first array.
|
|
14
|
+
* @param {T[]} arr2 - The second array.
|
|
15
|
+
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
|
|
16
|
+
* @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.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Custom mapping function for objects with an 'id' property
|
|
20
|
+
* const idMapper = obj => obj.id;
|
|
21
|
+
* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
|
|
22
|
+
* // Returns [{ id: 1 }, { id: 3 }]
|
|
23
|
+
*/
|
|
24
|
+
function xorBy(arr1, arr2, mapper) {
|
|
25
|
+
var union = unionBy(arr1, arr2, mapper);
|
|
26
|
+
var intersection = intersectionBy(arr1, arr2, mapper);
|
|
27
|
+
return differenceBy(union, intersection, mapper);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { xorBy };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { differenceWith } from './differenceWith.mjs';
|
|
2
|
+
import { intersectionWith } from './intersectionWith.mjs';
|
|
3
|
+
import { unionWith } from './unionWith.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Computes the symmetric difference between two arrays using a custom equality function.
|
|
7
|
+
* The symmetric difference is the set of elements which are in either of the arrays,
|
|
8
|
+
* but not in their intersection.
|
|
9
|
+
*
|
|
10
|
+
* @template T - Type of elements in the input arrays.
|
|
11
|
+
*
|
|
12
|
+
* @param {T[]} arr1 - The first array.
|
|
13
|
+
* @param {T[]} arr2 - The second array.
|
|
14
|
+
* @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
|
|
15
|
+
* @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.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Custom equality function for objects with an 'id' property
|
|
19
|
+
* const areObjectsEqual = (a, b) => a.id === b.id;
|
|
20
|
+
* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
|
|
21
|
+
* // Returns [{ id: 1 }, { id: 3 }]
|
|
22
|
+
*/
|
|
23
|
+
function xorWith(arr1, arr2, areElementsEqual) {
|
|
24
|
+
var union = unionWith(arr1, arr2, areElementsEqual);
|
|
25
|
+
var intersection = intersectionWith(arr1, arr2, areElementsEqual);
|
|
26
|
+
return differenceWith(union, intersection, areElementsEqual);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { xorWith };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { toConsumableArray as _toConsumableArray, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merges multiple arrays element-wise. Returns an array where each element is an array containing
|
|
5
|
+
* elements from the input arrays at the corresponding index.
|
|
6
|
+
*
|
|
7
|
+
* @param {T[]} arr1 - The first array to be zipped.
|
|
8
|
+
* @param {T[]} arr2 - The second array to be zipped.
|
|
9
|
+
* @param {T[]} arr3 - The third array to be zipped.
|
|
10
|
+
* @param {T[]} arr4 - The fourth array to be zipped.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function zip() {
|
|
14
|
+
var result = [];
|
|
15
|
+
for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
arrs[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
|
|
19
|
+
return x.length;
|
|
20
|
+
})));
|
|
21
|
+
for (var i = 0; i < maxIndex; i++) {
|
|
22
|
+
var element = [];
|
|
23
|
+
var _iterator = _createForOfIteratorHelper(arrs),
|
|
24
|
+
_step;
|
|
25
|
+
try {
|
|
26
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27
|
+
var arr = _step.value;
|
|
28
|
+
element.push(arr[i]);
|
|
29
|
+
}
|
|
30
|
+
} catch (err) {
|
|
31
|
+
_iterator.e(err);
|
|
32
|
+
} finally {
|
|
33
|
+
_iterator.f();
|
|
34
|
+
}
|
|
35
|
+
result.push(element);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { zip };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combines multiple arrays element-wise using a provided combining function.
|
|
5
|
+
* Returns an array where each element is the result of applying the combining function
|
|
6
|
+
* to the corresponding elements from the input arrays.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function zipWith(arr1) {
|
|
10
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
11
|
+
rest[_key - 1] = arguments[_key];
|
|
12
|
+
}
|
|
13
|
+
var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
|
|
14
|
+
var combine = rest[rest.length - 1];
|
|
15
|
+
var result = [];
|
|
16
|
+
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
|
|
17
|
+
return arr.length;
|
|
18
|
+
})));
|
|
19
|
+
var _loop = function _loop(i) {
|
|
20
|
+
var elements = arrs.map(function (arr) {
|
|
21
|
+
return arr[i];
|
|
22
|
+
});
|
|
23
|
+
result.push(combine.apply(void 0, _toConsumableArray(elements)));
|
|
24
|
+
};
|
|
25
|
+
for (var i = 0; i < maxIndex; i++) {
|
|
26
|
+
_loop(i);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { zipWith };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the provided function until after `waitMs` 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} waitMs - 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
|
+
function debounce(func, waitMs) {
|
|
22
|
+
var timeoutId = null;
|
|
23
|
+
var debounced = function debounced() {
|
|
24
|
+
if (timeoutId != null) {
|
|
25
|
+
clearTimeout(timeoutId);
|
|
26
|
+
}
|
|
27
|
+
timeoutId = setTimeout(function () {
|
|
28
|
+
func();
|
|
29
|
+
}, waitMs);
|
|
30
|
+
};
|
|
31
|
+
debounced.cancel = function () {
|
|
32
|
+
if (timeoutId != null) {
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return debounced;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { debounce };
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* @template F - The type of the function to be invoked once.
|
|
6
|
+
* @param {F} func - The function to restrict.
|
|
7
|
+
* @returns {F} A new function that invokes `func` once and caches the result.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const initialize = once(() => {
|
|
11
|
+
* console.log('Initialized!');
|
|
12
|
+
* return true;
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* initialize(); // Logs: 'Initialized!' and returns true
|
|
16
|
+
* initialize(); // Returns true without logging
|
|
17
|
+
*/
|
|
18
|
+
function once(func) {
|
|
19
|
+
var called = false;
|
|
20
|
+
var cache;
|
|
21
|
+
return function () {
|
|
22
|
+
if (called) {
|
|
23
|
+
return cache;
|
|
24
|
+
}
|
|
25
|
+
var result = func();
|
|
26
|
+
called = true;
|
|
27
|
+
cache = result;
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { once };
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
function throttle(func, throttleMs) {
|
|
27
|
+
var lastCallTime;
|
|
28
|
+
var throttledFunction = function throttledFunction() {
|
|
29
|
+
var now = Date.now();
|
|
30
|
+
if (lastCallTime == null || now - lastCallTime >= throttleMs) {
|
|
31
|
+
lastCallTime = now;
|
|
32
|
+
func();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return throttledFunction;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { throttle };
|
package/esm/index.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { chunk } from './array/chunk.mjs';
|
|
2
|
+
export { difference } from './array/difference.mjs';
|
|
3
|
+
export { differenceBy } from './array/differenceBy.mjs';
|
|
4
|
+
export { differenceWith } from './array/differenceWith.mjs';
|
|
5
|
+
export { drop } from './array/drop.mjs';
|
|
6
|
+
export { dropRight } from './array/dropRight.mjs';
|
|
7
|
+
export { dropRightWhile } from './array/dropRightWhile.mjs';
|
|
8
|
+
export { dropWhile } from './array/dropWhile.mjs';
|
|
9
|
+
export { groupBy } from './array/groupBy.mjs';
|
|
10
|
+
export { intersection } from './array/intersection.mjs';
|
|
11
|
+
export { intersectionBy } from './array/intersectionBy.mjs';
|
|
12
|
+
export { intersectionWith } from './array/intersectionWith.mjs';
|
|
13
|
+
export { partition } from './array/partition.mjs';
|
|
14
|
+
export { sample } from './array/sample.mjs';
|
|
15
|
+
export { shuffle } from './array/shuffle.mjs';
|
|
16
|
+
export { take } from './array/take.mjs';
|
|
17
|
+
export { takeRight } from './array/takeRight.mjs';
|
|
18
|
+
export { takeRightWhile } from './array/takeRightWhile.mjs';
|
|
19
|
+
export { takeWhile } from './array/takeWhile.mjs';
|
|
20
|
+
export { union } from './array/union.mjs';
|
|
21
|
+
export { unionBy } from './array/unionBy.mjs';
|
|
22
|
+
export { unionWith } from './array/unionWith.mjs';
|
|
23
|
+
export { uniq } from './array/uniq.mjs';
|
|
24
|
+
export { uniqBy } from './array/uniqBy.mjs';
|
|
25
|
+
export { uniqWith } from './array/uniqWith.mjs';
|
|
26
|
+
export { xor } from './array/xor.mjs';
|
|
27
|
+
export { xorBy } from './array/xorBy.mjs';
|
|
28
|
+
export { xorWith } from './array/xorWith.mjs';
|
|
29
|
+
export { zip } from './array/zip.mjs';
|
|
30
|
+
export { zipWith } from './array/zipWith.mjs';
|
|
31
|
+
export { debounce } from './function/debounce.mjs';
|
|
32
|
+
export { once } from './function/once.mjs';
|
|
33
|
+
export { throttle } from './function/throttle.mjs';
|
|
34
|
+
export { clamp } from './math/clamp.mjs';
|
|
35
|
+
export { round } from './math/round.mjs';
|
|
36
|
+
export { sum } from './math/sum.mjs';
|
|
37
|
+
export { omit } from './object/omit.mjs';
|
|
38
|
+
export { omitBy } from './object/omitBy.mjs';
|
|
39
|
+
export { pick } from './object/pick.mjs';
|
|
40
|
+
export { pickBy } from './object/pickBy.mjs';
|
|
41
|
+
export { isNil } from './predicate/isNil.mjs';
|
|
42
|
+
export { isNotNil } from './predicate/isNotNil.mjs';
|
|
43
|
+
export { isNull } from './predicate/isNull.mjs';
|
|
44
|
+
export { isUndefined } from './predicate/isUndefined.mjs';
|
|
45
|
+
export { delay } from './promise/delay.mjs';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name clamp
|
|
3
|
+
* @description Checks if `value` is within the bounds, if not return the closest bound (bound1: min, bound2: max)
|
|
4
|
+
* function clamp(value: number, bound1: number, bound2?: number): number
|
|
5
|
+
* @example
|
|
6
|
+
* clamp(3, 1) // 3
|
|
7
|
+
* clamp(3, 1, 5) // 3
|
|
8
|
+
* clamp(3, 5) // 5
|
|
9
|
+
* clamp(7, 3, 5) // 5
|
|
10
|
+
*/
|
|
11
|
+
function clamp(value, bound1, bound2) {
|
|
12
|
+
if (bound2 == null) {
|
|
13
|
+
return Math.min(value, bound1);
|
|
14
|
+
}
|
|
15
|
+
return Math.min(Math.max(value, bound1), bound2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { clamp };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name round
|
|
3
|
+
* @description Rounds given number to given precision
|
|
4
|
+
* ```typescript
|
|
5
|
+
* function round(value: number, precision: number = 0): number
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* round(1.2) === 1
|
|
10
|
+
* round(3.9) === 4
|
|
11
|
+
* round(8.5) === 9
|
|
12
|
+
*/
|
|
13
|
+
function round(value) {
|
|
14
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
15
|
+
var multiplier = Math.pow(10, precision);
|
|
16
|
+
return Math.round(value * multiplier) / multiplier;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { round };
|
package/esm/math/sum.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name sum
|
|
3
|
+
* @description Return the sum of given values.
|
|
4
|
+
* ```typescript
|
|
5
|
+
* function sum(...nums: number[] | number[][]): number;
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* sum(1, 2, 3) === 6
|
|
10
|
+
* sum(...[1, 2, 3]) === 6
|
|
11
|
+
* sum([1, 2, 3]) === 6
|
|
12
|
+
*/
|
|
13
|
+
function sum() {
|
|
14
|
+
for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
nums[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
return nums.flat().reduce(function (acc, curr) {
|
|
18
|
+
return acc + curr;
|
|
19
|
+
}, 0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { sum };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function ownKeys(e, r) {
|
|
2
|
+
var t = Object.keys(e);
|
|
3
|
+
if (Object.getOwnPropertySymbols) {
|
|
4
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
5
|
+
r && (o = o.filter(function (r) {
|
|
6
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
7
|
+
})), t.push.apply(t, o);
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
function _objectSpread2(e) {
|
|
12
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
13
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
14
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
15
|
+
_defineProperty(e, r, t[r]);
|
|
16
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
17
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
function _toPrimitive(t, r) {
|
|
23
|
+
if ("object" != typeof t || !t) return t;
|
|
24
|
+
var e = t[Symbol.toPrimitive];
|
|
25
|
+
if (void 0 !== e) {
|
|
26
|
+
var i = e.call(t, r || "default");
|
|
27
|
+
if ("object" != typeof i) return i;
|
|
28
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
29
|
+
}
|
|
30
|
+
return ("string" === r ? String : Number)(t);
|
|
31
|
+
}
|
|
32
|
+
function _toPropertyKey(t) {
|
|
33
|
+
var i = _toPrimitive(t, "string");
|
|
34
|
+
return "symbol" == typeof i ? i : i + "";
|
|
35
|
+
}
|
|
36
|
+
function _defineProperty(obj, key, value) {
|
|
37
|
+
key = _toPropertyKey(key);
|
|
38
|
+
if (key in obj) {
|
|
39
|
+
Object.defineProperty(obj, key, {
|
|
40
|
+
value: value,
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
obj[key] = value;
|
|
47
|
+
}
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
51
|
+
if (!o) return;
|
|
52
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
53
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
54
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
55
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
56
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
57
|
+
}
|
|
58
|
+
function _arrayLikeToArray(arr, len) {
|
|
59
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
60
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
61
|
+
return arr2;
|
|
62
|
+
}
|
|
63
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
64
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
65
|
+
if (!it) {
|
|
66
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
67
|
+
if (it) o = it;
|
|
68
|
+
var i = 0;
|
|
69
|
+
var F = function () {};
|
|
70
|
+
return {
|
|
71
|
+
s: F,
|
|
72
|
+
n: function () {
|
|
73
|
+
if (i >= o.length) return {
|
|
74
|
+
done: true
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
done: false,
|
|
78
|
+
value: o[i++]
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
e: function (e) {
|
|
82
|
+
throw e;
|
|
83
|
+
},
|
|
84
|
+
f: F
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
88
|
+
}
|
|
89
|
+
var normalCompletion = true,
|
|
90
|
+
didErr = false,
|
|
91
|
+
err;
|
|
92
|
+
return {
|
|
93
|
+
s: function () {
|
|
94
|
+
it = it.call(o);
|
|
95
|
+
},
|
|
96
|
+
n: function () {
|
|
97
|
+
var step = it.next();
|
|
98
|
+
normalCompletion = step.done;
|
|
99
|
+
return step;
|
|
100
|
+
},
|
|
101
|
+
e: function (e) {
|
|
102
|
+
didErr = true;
|
|
103
|
+
err = e;
|
|
104
|
+
},
|
|
105
|
+
f: function () {
|
|
106
|
+
try {
|
|
107
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
108
|
+
} finally {
|
|
109
|
+
if (didErr) throw err;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { _arrayLikeToArray as arrayLikeToArray, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @name omit
|
|
5
|
+
* Omit properties from an object.
|
|
6
|
+
* @param obj The object to omit properties from
|
|
7
|
+
* @param keys The keys to omit from an object
|
|
8
|
+
*/
|
|
9
|
+
function omit(obj, keys) {
|
|
10
|
+
var result = _objectSpread2({}, obj);
|
|
11
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
12
|
+
_step;
|
|
13
|
+
try {
|
|
14
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15
|
+
var key = _step.value;
|
|
16
|
+
delete result[key];
|
|
17
|
+
}
|
|
18
|
+
} catch (err) {
|
|
19
|
+
_iterator.e(err);
|
|
20
|
+
} finally {
|
|
21
|
+
_iterator.f();
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { omit };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @name pick
|
|
5
|
+
* Pick properties from an given object.
|
|
6
|
+
* @param obj The object to pick properties from
|
|
7
|
+
* @param keys The keys to pick from an object
|
|
8
|
+
*/
|
|
9
|
+
function pick(obj, keys) {
|
|
10
|
+
var result = {};
|
|
11
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
12
|
+
_step;
|
|
13
|
+
try {
|
|
14
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15
|
+
var key = _step.value;
|
|
16
|
+
result[key] = obj[key];
|
|
17
|
+
}
|
|
18
|
+
} catch (err) {
|
|
19
|
+
_iterator.e(err);
|
|
20
|
+
} finally {
|
|
21
|
+
_iterator.f();
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { pick };
|