es-toolkit 0.0.1-dev.20
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 +5 -0
- package/README.md +31 -0
- package/dist/array/chunk.d.ts +24 -0
- package/dist/array/chunk.spec.d.ts +1 -0
- package/dist/array/difference.d.ts +23 -0
- package/dist/array/difference.spec.d.ts +1 -0
- package/dist/array/differenceBy.d.ts +26 -0
- package/dist/array/differenceBy.spec.d.ts +1 -0
- package/dist/array/differenceWith.d.ts +22 -0
- package/dist/array/differenceWith.spec.d.ts +1 -0
- package/dist/array/drop.d.ts +16 -0
- package/dist/array/drop.spec.d.ts +1 -0
- package/dist/array/dropRight.d.ts +16 -0
- package/dist/array/dropRight.spec.d.ts +1 -0
- package/dist/array/dropRightWhile.d.ts +18 -0
- package/dist/array/dropRightWhile.spec.d.ts +1 -0
- package/dist/array/dropWhile.d.ts +18 -0
- package/dist/array/dropWhile.spec.d.ts +1 -0
- package/dist/array/groupBy.d.ts +31 -0
- package/dist/array/groupBy.spec.d.ts +1 -0
- package/dist/array/index.d.ts +30 -0
- package/dist/array/index.js +991 -0
- package/dist/array/intersection.d.ts +18 -0
- package/dist/array/intersection.spec.d.ts +1 -0
- package/dist/array/intersectionBy.d.ts +21 -0
- package/dist/array/intersectionBy.spec.d.ts +1 -0
- package/dist/array/intersectionWith.d.ts +22 -0
- package/dist/array/intersectionWith.spec.d.ts +1 -0
- package/dist/array/partition.d.ts +22 -0
- package/dist/array/partition.spec.d.ts +1 -0
- package/dist/array/sample.d.ts +14 -0
- package/dist/array/sample.spec.d.ts +1 -0
- package/dist/array/shuffle.d.ts +14 -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 +21 -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 +17 -0
- package/dist/array/union.spec.d.ts +1 -0
- package/dist/array/unionBy.d.ts +21 -0
- package/dist/array/unionBy.spec.d.ts +1 -0
- package/dist/array/unionWith.d.ts +20 -0
- package/dist/array/unionWith.spec.d.ts +1 -0
- package/dist/array/uniq.d.ts +15 -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 +17 -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 +25 -0
- package/dist/array/zip.spec.d.ts +1 -0
- package/dist/array/zipWith.d.ts +32 -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 +112 -0
- package/dist/function/once.d.ts +17 -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 +1514 -0
- package/dist/math/clamp.d.ts +19 -0
- package/dist/math/clamp.spec.d.ts +1 -0
- package/dist/math/index.d.ts +3 -0
- package/dist/math/index.js +148 -0
- package/dist/math/round.d.ts +16 -0
- package/dist/math/round.spec.d.ts +1 -0
- package/dist/math/sum.d.ts +14 -0
- package/dist/math/sum.spec.d.ts +1 -0
- package/dist/object/index.d.ts +4 -0
- package/dist/object/index.js +286 -0
- package/dist/object/omit.d.ts +16 -0
- package/dist/object/omit.spec.d.ts +1 -0
- package/dist/object/omitBy.d.ts +19 -0
- package/dist/object/omitBy.spec.d.ts +1 -0
- package/dist/object/pick.d.ts +16 -0
- package/dist/object/pick.spec.d.ts +1 -0
- package/dist/object/pickBy.d.ts +19 -0
- package/dist/object/pickBy.spec.d.ts +1 -0
- package/dist/predicate/index.d.ts +4 -0
- package/dist/predicate/index.js +98 -0
- package/dist/predicate/isNil.d.ts +20 -0
- package/dist/predicate/isNil.spec.d.ts +1 -0
- package/dist/predicate/isNotNil.d.ts +16 -0
- package/dist/predicate/isNotNil.spec.d.ts +1 -0
- package/dist/predicate/isNull.d.ts +21 -0
- package/dist/predicate/isNull.spec.d.ts +1 -0
- package/dist/predicate/isUndefined.d.ts +21 -0
- package/dist/predicate/isUndefined.spec.d.ts +1 -0
- package/dist/promise/delay.d.ts +19 -0
- package/dist/promise/delay.spec.d.ts +1 -0
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/index.js +29 -0
- package/esm/_virtual/_rollupPluginBabelHelpers.mjs +163 -0
- package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +78 -0
- package/esm/array/chunk.mjs +38 -0
- package/esm/array/difference.mjs +29 -0
- package/esm/array/differenceBy.mjs +35 -0
- package/esm/array/differenceWith.mjs +30 -0
- package/esm/array/drop.mjs +20 -0
- package/esm/array/dropRight.mjs +20 -0
- package/esm/array/dropRightWhile.mjs +26 -0
- package/esm/array/dropWhile.mjs +25 -0
- package/esm/array/groupBy.mjs +54 -0
- package/esm/array/index.mjs +30 -0
- package/esm/array/intersection.mjs +24 -0
- package/esm/array/intersectionBy.mjs +30 -0
- package/esm/array/intersectionWith.mjs +30 -0
- package/esm/array/partition.mjs +46 -0
- package/esm/array/sample.mjs +19 -0
- package/esm/array/shuffle.mjs +27 -0
- package/esm/array/take.mjs +27 -0
- package/esm/array/takeRight.mjs +28 -0
- package/esm/array/takeRightWhile.mjs +27 -0
- package/esm/array/takeWhile.mjs +41 -0
- package/esm/array/union.mjs +23 -0
- package/esm/array/unionBy.mjs +35 -0
- package/esm/array/unionWith.mjs +26 -0
- package/esm/array/uniq.mjs +37 -0
- package/esm/array/uniqBy.mjs +20 -0
- package/esm/array/uniqWith.mjs +39 -0
- package/esm/array/xor.mjs +25 -0
- package/esm/array/xorBy.mjs +30 -0
- package/esm/array/xorWith.mjs +29 -0
- package/esm/array/zip.mjs +52 -0
- package/esm/array/zipWith.mjs +54 -0
- package/esm/function/debounce.mjs +39 -0
- package/esm/function/index.mjs +3 -0
- package/esm/function/once.mjs +31 -0
- package/esm/function/throttle.mjs +38 -0
- package/esm/index.mjs +45 -0
- package/esm/math/_virtual/_rollupPluginBabelHelpers.mjs +66 -0
- package/esm/math/clamp.mjs +26 -0
- package/esm/math/index.mjs +3 -0
- package/esm/math/round.mjs +22 -0
- package/esm/math/sum.mjs +33 -0
- package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +151 -0
- package/esm/object/index.mjs +4 -0
- package/esm/object/omit.mjs +35 -0
- package/esm/object/omitBy.mjs +35 -0
- package/esm/object/pick.mjs +35 -0
- package/esm/object/pickBy.mjs +35 -0
- package/esm/predicate/index.mjs +4 -0
- package/esm/predicate/isNil.mjs +24 -0
- package/esm/predicate/isNotNil.mjs +20 -0
- package/esm/predicate/isNull.mjs +25 -0
- package/esm/predicate/isUndefined.mjs +25 -0
- package/esm/promise/delay.mjs +25 -0
- package/esm/promise/index.mjs +1 -0
- package/package.json +108 -0
|
@@ -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 {};
|