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,11 @@
|
|
|
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
|
+
export declare function clamp(value: number, bound1: number, bound2?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @name clamp
|
|
7
|
+
* @description Checks if `value` is within the bounds, if not return the closest bound (bound1: min, bound2: max)
|
|
8
|
+
* function clamp(value: number, bound1: number, bound2?: number): number
|
|
9
|
+
* @example
|
|
10
|
+
* clamp(3, 1) // 3
|
|
11
|
+
* clamp(3, 1, 5) // 3
|
|
12
|
+
* clamp(3, 5) // 5
|
|
13
|
+
* clamp(7, 3, 5) // 5
|
|
14
|
+
*/
|
|
15
|
+
function clamp(value, bound1, bound2) {
|
|
16
|
+
if (bound2 == null) {
|
|
17
|
+
return Math.min(value, bound1);
|
|
18
|
+
}
|
|
19
|
+
return Math.min(Math.max(value, bound1), bound2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @name round
|
|
24
|
+
* @description Rounds given number to given precision
|
|
25
|
+
* ```typescript
|
|
26
|
+
* function round(value: number, precision: number = 0): number
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* round(1.2) === 1
|
|
31
|
+
* round(3.9) === 4
|
|
32
|
+
* round(8.5) === 9
|
|
33
|
+
*/
|
|
34
|
+
function round(value) {
|
|
35
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
36
|
+
var multiplier = Math.pow(10, precision);
|
|
37
|
+
return Math.round(value * multiplier) / multiplier;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @name sum
|
|
42
|
+
* @description Return the sum of given values.
|
|
43
|
+
* ```typescript
|
|
44
|
+
* function sum(...nums: number[] | number[][]): number;
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* sum(1, 2, 3) === 6
|
|
49
|
+
* sum(...[1, 2, 3]) === 6
|
|
50
|
+
* sum([1, 2, 3]) === 6
|
|
51
|
+
*/
|
|
52
|
+
function sum() {
|
|
53
|
+
for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
|
+
nums[_key] = arguments[_key];
|
|
55
|
+
}
|
|
56
|
+
return nums.flat().reduce(function (acc, curr) {
|
|
57
|
+
return acc + curr;
|
|
58
|
+
}, 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.clamp = clamp;
|
|
62
|
+
exports.round = round;
|
|
63
|
+
exports.sum = sum;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export declare function round(value: number, precision?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export declare function sum(...nums: number[] | number[][]): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function ownKeys(e, r) {
|
|
6
|
+
var t = Object.keys(e);
|
|
7
|
+
if (Object.getOwnPropertySymbols) {
|
|
8
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
9
|
+
r && (o = o.filter(function (r) {
|
|
10
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
11
|
+
})), t.push.apply(t, o);
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
function _objectSpread2(e) {
|
|
16
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
17
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
18
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
19
|
+
_defineProperty(e, r, t[r]);
|
|
20
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
21
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
function _toPrimitive(t, r) {
|
|
27
|
+
if ("object" != typeof t || !t) return t;
|
|
28
|
+
var e = t[Symbol.toPrimitive];
|
|
29
|
+
if (void 0 !== e) {
|
|
30
|
+
var i = e.call(t, r || "default");
|
|
31
|
+
if ("object" != typeof i) return i;
|
|
32
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
33
|
+
}
|
|
34
|
+
return ("string" === r ? String : Number)(t);
|
|
35
|
+
}
|
|
36
|
+
function _toPropertyKey(t) {
|
|
37
|
+
var i = _toPrimitive(t, "string");
|
|
38
|
+
return "symbol" == typeof i ? i : i + "";
|
|
39
|
+
}
|
|
40
|
+
function _defineProperty(obj, key, value) {
|
|
41
|
+
key = _toPropertyKey(key);
|
|
42
|
+
if (key in obj) {
|
|
43
|
+
Object.defineProperty(obj, key, {
|
|
44
|
+
value: value,
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
obj[key] = value;
|
|
51
|
+
}
|
|
52
|
+
return obj;
|
|
53
|
+
}
|
|
54
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
55
|
+
if (!o) return;
|
|
56
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
57
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
58
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
59
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
60
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
61
|
+
}
|
|
62
|
+
function _arrayLikeToArray(arr, len) {
|
|
63
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
64
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
65
|
+
return arr2;
|
|
66
|
+
}
|
|
67
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
68
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
69
|
+
if (!it) {
|
|
70
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
71
|
+
if (it) o = it;
|
|
72
|
+
var i = 0;
|
|
73
|
+
var F = function () {};
|
|
74
|
+
return {
|
|
75
|
+
s: F,
|
|
76
|
+
n: function () {
|
|
77
|
+
if (i >= o.length) return {
|
|
78
|
+
done: true
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
done: false,
|
|
82
|
+
value: o[i++]
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
e: function (e) {
|
|
86
|
+
throw e;
|
|
87
|
+
},
|
|
88
|
+
f: F
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
+
}
|
|
93
|
+
var normalCompletion = true,
|
|
94
|
+
didErr = false,
|
|
95
|
+
err;
|
|
96
|
+
return {
|
|
97
|
+
s: function () {
|
|
98
|
+
it = it.call(o);
|
|
99
|
+
},
|
|
100
|
+
n: function () {
|
|
101
|
+
var step = it.next();
|
|
102
|
+
normalCompletion = step.done;
|
|
103
|
+
return step;
|
|
104
|
+
},
|
|
105
|
+
e: function (e) {
|
|
106
|
+
didErr = true;
|
|
107
|
+
err = e;
|
|
108
|
+
},
|
|
109
|
+
f: function () {
|
|
110
|
+
try {
|
|
111
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
112
|
+
} finally {
|
|
113
|
+
if (didErr) throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @name omit
|
|
121
|
+
* Omit properties from an object.
|
|
122
|
+
* @param obj The object to omit properties from
|
|
123
|
+
* @param keys The keys to omit from an object
|
|
124
|
+
*/
|
|
125
|
+
function omit(obj, keys) {
|
|
126
|
+
var result = _objectSpread2({}, obj);
|
|
127
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
128
|
+
_step;
|
|
129
|
+
try {
|
|
130
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
131
|
+
var key = _step.value;
|
|
132
|
+
delete result[key];
|
|
133
|
+
}
|
|
134
|
+
} catch (err) {
|
|
135
|
+
_iterator.e(err);
|
|
136
|
+
} finally {
|
|
137
|
+
_iterator.f();
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function omitBy() {
|
|
143
|
+
throw new Error('Not implemented');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @name pick
|
|
148
|
+
* Pick properties from an given object.
|
|
149
|
+
* @param obj The object to pick properties from
|
|
150
|
+
* @param keys The keys to pick from an object
|
|
151
|
+
*/
|
|
152
|
+
function pick(obj, keys) {
|
|
153
|
+
var result = {};
|
|
154
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
155
|
+
_step;
|
|
156
|
+
try {
|
|
157
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
158
|
+
var key = _step.value;
|
|
159
|
+
result[key] = obj[key];
|
|
160
|
+
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
_iterator.e(err);
|
|
163
|
+
} finally {
|
|
164
|
+
_iterator.f();
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function pickBy() {
|
|
170
|
+
throw new Error('Not implemented');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
exports.omit = omit;
|
|
174
|
+
exports.omitBy = omitBy;
|
|
175
|
+
exports.pick = pick;
|
|
176
|
+
exports.pickBy = pickBy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function omitBy(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pickBy(): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @name isNil
|
|
7
|
+
* Checks if the given value is null or undefined.
|
|
8
|
+
* @param x The value to test if it is null or undefined
|
|
9
|
+
*/
|
|
10
|
+
function isNil(x) {
|
|
11
|
+
return x == null || x == undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @name isNotNil
|
|
16
|
+
* Checks if the given value is not null nor undefined.
|
|
17
|
+
* The main use of this function is to used with TypeScript as a type predicate.
|
|
18
|
+
* @param x The value to test if it is not null nor undefined
|
|
19
|
+
* @example
|
|
20
|
+
* // Here the type of `arr` is (number | undefined)[]
|
|
21
|
+
* const arr = [1, undefined, 3];
|
|
22
|
+
* // Here the type of `result` is number[]
|
|
23
|
+
* const result = arr.filter(isNotNil);
|
|
24
|
+
*/
|
|
25
|
+
function isNotNil(x) {
|
|
26
|
+
return x != null && x != undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @name isNull
|
|
31
|
+
* Checks if the given value is null.
|
|
32
|
+
* @param x The value to test if it is null
|
|
33
|
+
*/
|
|
34
|
+
function isNull(x) {
|
|
35
|
+
return x === null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @name isUndefined
|
|
40
|
+
* Checks if the given value is undefined.
|
|
41
|
+
* @param x The value to test if it is undefined
|
|
42
|
+
*/
|
|
43
|
+
function isUndefined(x) {
|
|
44
|
+
return x === undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.isNil = isNil;
|
|
48
|
+
exports.isNotNil = isNotNil;
|
|
49
|
+
exports.isNull = isNull;
|
|
50
|
+
exports.isUndefined = isUndefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name isNotNil
|
|
3
|
+
* Checks if the given value is not null nor undefined.
|
|
4
|
+
* The main use of this function is to used with TypeScript as a type predicate.
|
|
5
|
+
* @param x The value to test if it is not null nor undefined
|
|
6
|
+
* @example
|
|
7
|
+
* // Here the type of `arr` is (number | undefined)[]
|
|
8
|
+
* const arr = [1, undefined, 3];
|
|
9
|
+
* // Here the type of `result` is number[]
|
|
10
|
+
* const result = arr.filter(isNotNil);
|
|
11
|
+
*/
|
|
12
|
+
export declare function isNotNil<T>(x: T | null | undefined): x is T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { delay } from './delay';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @name delay
|
|
7
|
+
* Pause the execution of a function for given milliseconds.
|
|
8
|
+
* @param ms The amount of time to delay the function.
|
|
9
|
+
*/
|
|
10
|
+
function delay(ms) {
|
|
11
|
+
return new Promise(function (resolve) {
|
|
12
|
+
setTimeout(resolve, ms);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.delay = delay;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
function _iterableToArrayLimit(r, l) {
|
|
2
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
3
|
+
if (null != t) {
|
|
4
|
+
var e,
|
|
5
|
+
n,
|
|
6
|
+
i,
|
|
7
|
+
u,
|
|
8
|
+
a = [],
|
|
9
|
+
f = !0,
|
|
10
|
+
o = !1;
|
|
11
|
+
try {
|
|
12
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
13
|
+
if (Object(t) !== t) return;
|
|
14
|
+
f = !1;
|
|
15
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
16
|
+
} catch (r) {
|
|
17
|
+
o = !0, n = r;
|
|
18
|
+
} finally {
|
|
19
|
+
try {
|
|
20
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
21
|
+
} finally {
|
|
22
|
+
if (o) throw n;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function ownKeys(e, r) {
|
|
29
|
+
var t = Object.keys(e);
|
|
30
|
+
if (Object.getOwnPropertySymbols) {
|
|
31
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
32
|
+
r && (o = o.filter(function (r) {
|
|
33
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
34
|
+
})), t.push.apply(t, o);
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
function _objectSpread2(e) {
|
|
39
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
40
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
41
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
42
|
+
_defineProperty(e, r, t[r]);
|
|
43
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
44
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
function _toPrimitive(t, r) {
|
|
50
|
+
if ("object" != typeof t || !t) return t;
|
|
51
|
+
var e = t[Symbol.toPrimitive];
|
|
52
|
+
if (void 0 !== e) {
|
|
53
|
+
var i = e.call(t, r || "default");
|
|
54
|
+
if ("object" != typeof i) return i;
|
|
55
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
56
|
+
}
|
|
57
|
+
return ("string" === r ? String : Number)(t);
|
|
58
|
+
}
|
|
59
|
+
function _toPropertyKey(t) {
|
|
60
|
+
var i = _toPrimitive(t, "string");
|
|
61
|
+
return "symbol" == typeof i ? i : i + "";
|
|
62
|
+
}
|
|
63
|
+
function _defineProperty(obj, key, value) {
|
|
64
|
+
key = _toPropertyKey(key);
|
|
65
|
+
if (key in obj) {
|
|
66
|
+
Object.defineProperty(obj, key, {
|
|
67
|
+
value: value,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
obj[key] = value;
|
|
74
|
+
}
|
|
75
|
+
return obj;
|
|
76
|
+
}
|
|
77
|
+
function _slicedToArray(arr, i) {
|
|
78
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
79
|
+
}
|
|
80
|
+
function _toConsumableArray(arr) {
|
|
81
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
82
|
+
}
|
|
83
|
+
function _arrayWithoutHoles(arr) {
|
|
84
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
85
|
+
}
|
|
86
|
+
function _arrayWithHoles(arr) {
|
|
87
|
+
if (Array.isArray(arr)) return arr;
|
|
88
|
+
}
|
|
89
|
+
function _iterableToArray(iter) {
|
|
90
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
91
|
+
}
|
|
92
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
93
|
+
if (!o) return;
|
|
94
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
95
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
96
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
97
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
98
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
99
|
+
}
|
|
100
|
+
function _arrayLikeToArray(arr, len) {
|
|
101
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
102
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
103
|
+
return arr2;
|
|
104
|
+
}
|
|
105
|
+
function _nonIterableSpread() {
|
|
106
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
107
|
+
}
|
|
108
|
+
function _nonIterableRest() {
|
|
109
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
110
|
+
}
|
|
111
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
112
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
113
|
+
if (!it) {
|
|
114
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
115
|
+
if (it) o = it;
|
|
116
|
+
var i = 0;
|
|
117
|
+
var F = function () {};
|
|
118
|
+
return {
|
|
119
|
+
s: F,
|
|
120
|
+
n: function () {
|
|
121
|
+
if (i >= o.length) return {
|
|
122
|
+
done: true
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
done: false,
|
|
126
|
+
value: o[i++]
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
e: function (e) {
|
|
130
|
+
throw e;
|
|
131
|
+
},
|
|
132
|
+
f: F
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
136
|
+
}
|
|
137
|
+
var normalCompletion = true,
|
|
138
|
+
didErr = false,
|
|
139
|
+
err;
|
|
140
|
+
return {
|
|
141
|
+
s: function () {
|
|
142
|
+
it = it.call(o);
|
|
143
|
+
},
|
|
144
|
+
n: function () {
|
|
145
|
+
var step = it.next();
|
|
146
|
+
normalCompletion = step.done;
|
|
147
|
+
return step;
|
|
148
|
+
},
|
|
149
|
+
e: function (e) {
|
|
150
|
+
didErr = true;
|
|
151
|
+
err = e;
|
|
152
|
+
},
|
|
153
|
+
f: function () {
|
|
154
|
+
try {
|
|
155
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
156
|
+
} finally {
|
|
157
|
+
if (didErr) throw err;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
|