es-toolkit 1.0.4 → 1.1.0-dev.45
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 +6 -0
- package/README.md +0 -1
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/difference.d.mts +1 -1
- package/dist/array/difference.d.ts +1 -1
- package/dist/array/difference.js +2 -3
- package/dist/array/difference.js.map +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.js.map +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.js.map +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -2
- package/dist/array/dropWhile.js.map +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/index.js +2 -3
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +30 -30
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.js.map +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.js.map +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/partition.js.map +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.js.map +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/shuffle.js.map +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/take.js.map +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.js.map +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.js.map +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.js.map +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/union.js.map +1 -1
- package/dist/array/union.mjs +2 -2
- package/dist/array/unionBy.js.map +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.js.map +1 -1
- package/dist/array/unionWith.mjs +2 -2
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +2 -2
- package/dist/array/uniqWith.js.map +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/xor.js +2 -3
- package/dist/array/xor.js.map +1 -1
- package/dist/array/xor.mjs +5 -5
- package/dist/array/xorBy.js.map +1 -1
- package/dist/array/xorBy.mjs +4 -4
- package/dist/array/xorWith.js.map +1 -1
- package/dist/array/xorWith.mjs +5 -5
- package/dist/array/zip.js.map +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/{chunk-TOLR2FNF.mjs → chunk-23DC774L.mjs} +1 -1
- package/dist/chunk-23DC774L.mjs.map +1 -0
- package/dist/{chunk-S767XFOS.mjs → chunk-3PFYAKOD.mjs} +1 -1
- package/dist/chunk-3PFYAKOD.mjs.map +1 -0
- package/dist/{chunk-NYVT33DR.mjs → chunk-6BCRFIEW.mjs} +1 -1
- package/dist/chunk-6BCRFIEW.mjs.map +1 -0
- package/dist/{chunk-VACGGQOL.mjs → chunk-6GRNTXI3.mjs} +1 -1
- package/dist/chunk-6GRNTXI3.mjs.map +1 -0
- package/dist/{chunk-SGSQKXDO.mjs → chunk-6LDIBBWQ.mjs} +2 -2
- package/dist/chunk-6LDIBBWQ.mjs.map +1 -0
- package/dist/{chunk-GJM7F3TH.mjs → chunk-7LAOIS6P.mjs} +1 -1
- package/dist/chunk-7LAOIS6P.mjs.map +1 -0
- package/dist/{chunk-724PNXPR.mjs → chunk-AFYV2UVZ.mjs} +1 -1
- package/dist/chunk-AFYV2UVZ.mjs.map +1 -0
- package/dist/{chunk-2VB6XU3I.mjs → chunk-ANJSX6WH.mjs} +1 -1
- package/dist/chunk-ANJSX6WH.mjs.map +1 -0
- package/dist/{chunk-OBMK7JO2.mjs → chunk-B5P232BA.mjs} +1 -1
- package/dist/chunk-B5P232BA.mjs.map +1 -0
- package/dist/{chunk-L4Y3G6AJ.mjs → chunk-GELVVASW.mjs} +3 -3
- package/dist/chunk-GELVVASW.mjs.map +1 -0
- package/dist/{chunk-RLDY4N3Q.mjs → chunk-GLAZTR32.mjs} +2 -2
- package/dist/chunk-GLAZTR32.mjs.map +1 -0
- package/dist/{chunk-NK2262VG.mjs → chunk-HOQRMBSB.mjs} +1 -1
- package/dist/chunk-HOQRMBSB.mjs.map +1 -0
- package/dist/{chunk-PWMHSN27.mjs → chunk-IFCX35BI.mjs} +1 -1
- package/dist/chunk-IFCX35BI.mjs.map +1 -0
- package/dist/{chunk-UZP4YX7I.mjs → chunk-J6SWM4X6.mjs} +1 -1
- package/dist/chunk-J6SWM4X6.mjs.map +1 -0
- package/dist/{chunk-QRQPLMV4.mjs → chunk-JDMFIUGM.mjs} +1 -1
- package/dist/chunk-JDMFIUGM.mjs.map +1 -0
- package/dist/{chunk-WFQ3LAHQ.mjs → chunk-KBJTBR5T.mjs} +1 -1
- package/dist/chunk-KBJTBR5T.mjs.map +1 -0
- package/dist/{chunk-5JWSGT4R.mjs → chunk-L25VRQ54.mjs} +1 -1
- package/dist/chunk-L25VRQ54.mjs.map +1 -0
- package/dist/{chunk-BAJC3BM7.mjs → chunk-L3C6TG2V.mjs} +1 -1
- package/dist/chunk-L3C6TG2V.mjs.map +1 -0
- package/dist/{chunk-2KXLTAVK.mjs → chunk-LLOAPSQ6.mjs} +1 -1
- package/dist/{chunk-2KXLTAVK.mjs.map → chunk-LLOAPSQ6.mjs.map} +1 -1
- package/dist/{chunk-NSYWEYWT.mjs → chunk-M3SHJ3LL.mjs} +1 -1
- package/dist/chunk-M3SHJ3LL.mjs.map +1 -0
- package/dist/{chunk-HQF6OFGM.mjs → chunk-OLBUAFBX.mjs} +1 -1
- package/dist/chunk-OLBUAFBX.mjs.map +1 -0
- package/dist/{chunk-35TWSMYS.mjs → chunk-OS5PZ4B4.mjs} +1 -1
- package/dist/{chunk-35TWSMYS.mjs.map → chunk-OS5PZ4B4.mjs.map} +1 -1
- package/dist/{chunk-J3NTLMAE.mjs → chunk-PHG5JCSW.mjs} +1 -1
- package/dist/chunk-PHG5JCSW.mjs.map +1 -0
- package/dist/{chunk-RU3RXBUC.mjs → chunk-PRTIPC5X.mjs} +1 -1
- package/dist/chunk-PRTIPC5X.mjs.map +1 -0
- package/dist/{chunk-EAI6NLXI.mjs → chunk-PUQLVKMB.mjs} +1 -1
- package/dist/chunk-PUQLVKMB.mjs.map +1 -0
- package/dist/{chunk-Z4IO7EIH.mjs → chunk-SF3V7XXM.mjs} +1 -1
- package/dist/chunk-SF3V7XXM.mjs.map +1 -0
- package/dist/chunk-SORNYLIU.mjs +10 -0
- package/dist/chunk-SORNYLIU.mjs.map +1 -0
- package/dist/{chunk-7PPND7QY.mjs → chunk-SPLO5OZW.mjs} +1 -1
- package/dist/chunk-SPLO5OZW.mjs.map +1 -0
- package/dist/{chunk-EAI4DDCQ.mjs → chunk-SQOYF647.mjs} +1 -1
- package/dist/chunk-SQOYF647.mjs.map +1 -0
- package/dist/{chunk-XW452I77.mjs → chunk-T2C2WVFL.mjs} +1 -1
- package/dist/chunk-T2C2WVFL.mjs.map +1 -0
- package/dist/{chunk-XS4ZPJMT.mjs → chunk-TCHT4HCP.mjs} +4 -4
- package/dist/chunk-TCHT4HCP.mjs.map +1 -0
- package/dist/{chunk-NEMQJ2GF.mjs → chunk-TF6N37OE.mjs} +1 -1
- package/dist/chunk-TF6N37OE.mjs.map +1 -0
- package/dist/{chunk-JMLFPGZ3.mjs → chunk-TK2EDHSP.mjs} +2 -2
- package/dist/chunk-TK2EDHSP.mjs.map +1 -0
- package/dist/{chunk-R5DNKXDI.mjs → chunk-TULUUJ3E.mjs} +4 -4
- package/dist/chunk-TULUUJ3E.mjs.map +1 -0
- package/dist/{chunk-ARWKEQMQ.mjs → chunk-UFAA5WKR.mjs} +1 -1
- package/dist/chunk-UFAA5WKR.mjs.map +1 -0
- package/dist/{chunk-UNX3KZO2.mjs → chunk-V6LXSPMF.mjs} +1 -1
- package/dist/chunk-V6LXSPMF.mjs.map +1 -0
- package/dist/{chunk-7OZZODAE.mjs → chunk-VKVA56XG.mjs} +4 -4
- package/dist/chunk-VKVA56XG.mjs.map +1 -0
- package/dist/{chunk-VAKCSKGR.mjs → chunk-XLO3QZVY.mjs} +3 -3
- package/dist/chunk-XLO3QZVY.mjs.map +1 -0
- package/dist/{chunk-FUWEG5ZM.mjs → chunk-Y6ZRNII6.mjs} +1 -1
- package/dist/chunk-Y6ZRNII6.mjs.map +1 -0
- package/dist/{chunk-VJGGYY4Y.mjs → chunk-YEZIGQJG.mjs} +2 -2
- package/dist/chunk-YEZIGQJG.mjs.map +1 -0
- package/dist/{chunk-LAZNLIBJ.mjs → chunk-YHY2XTJW.mjs} +1 -1
- package/dist/chunk-YHY2XTJW.mjs.map +1 -0
- package/dist/{chunk-7GWOR247.mjs → chunk-YNRYG5OB.mjs} +1 -1
- package/dist/chunk-YNRYG5OB.mjs.map +1 -0
- package/dist/{chunk-7SJHJHBN.mjs → chunk-ZBG3EYM3.mjs} +1 -1
- package/dist/chunk-ZBG3EYM3.mjs.map +1 -0
- package/dist/{chunk-YMNXRH52.mjs → chunk-ZQNAZPSK.mjs} +1 -1
- package/dist/chunk-ZQNAZPSK.mjs.map +1 -0
- package/dist/function/debounce.d.mts +3 -4
- package/dist/function/debounce.d.ts +3 -4
- package/dist/function/debounce.js +2 -2
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.js +4 -4
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/function/once.js.map +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.d.mts +3 -3
- package/dist/function/throttle.d.ts +3 -3
- package/dist/function/throttle.js +2 -2
- package/dist/function/throttle.js.map +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -44
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +2 -2
- package/dist/math/round.js.map +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +1 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +4 -4
- package/dist/object/omit.js.map +1 -1
- package/dist/object/omit.mjs +1 -1
- package/dist/object/omitBy.js.map +1 -1
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.js.map +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.js.map +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +4 -4
- package/dist/predicate/isNil.js.map +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNotNil.js.map +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.js.map +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.js.map +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.js.map +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +1 -1
- package/package.json +3 -2
- package/dist/chunk-2VB6XU3I.mjs.map +0 -1
- package/dist/chunk-5JWSGT4R.mjs.map +0 -1
- package/dist/chunk-724PNXPR.mjs.map +0 -1
- package/dist/chunk-7GWOR247.mjs.map +0 -1
- package/dist/chunk-7OZZODAE.mjs.map +0 -1
- package/dist/chunk-7PPND7QY.mjs.map +0 -1
- package/dist/chunk-7SJHJHBN.mjs.map +0 -1
- package/dist/chunk-ARWKEQMQ.mjs.map +0 -1
- package/dist/chunk-BAJC3BM7.mjs.map +0 -1
- package/dist/chunk-EAI4DDCQ.mjs.map +0 -1
- package/dist/chunk-EAI6NLXI.mjs.map +0 -1
- package/dist/chunk-FUWEG5ZM.mjs.map +0 -1
- package/dist/chunk-GJM7F3TH.mjs.map +0 -1
- package/dist/chunk-HQF6OFGM.mjs.map +0 -1
- package/dist/chunk-J3NTLMAE.mjs.map +0 -1
- package/dist/chunk-JMLFPGZ3.mjs.map +0 -1
- package/dist/chunk-L4Y3G6AJ.mjs.map +0 -1
- package/dist/chunk-LAZNLIBJ.mjs.map +0 -1
- package/dist/chunk-NEMQJ2GF.mjs.map +0 -1
- package/dist/chunk-NK2262VG.mjs.map +0 -1
- package/dist/chunk-NSYWEYWT.mjs.map +0 -1
- package/dist/chunk-NYVT33DR.mjs.map +0 -1
- package/dist/chunk-OBMK7JO2.mjs.map +0 -1
- package/dist/chunk-PTQLD7TG.mjs +0 -11
- package/dist/chunk-PTQLD7TG.mjs.map +0 -1
- package/dist/chunk-PWMHSN27.mjs.map +0 -1
- package/dist/chunk-QRQPLMV4.mjs.map +0 -1
- package/dist/chunk-R5DNKXDI.mjs.map +0 -1
- package/dist/chunk-RLDY4N3Q.mjs.map +0 -1
- package/dist/chunk-RU3RXBUC.mjs.map +0 -1
- package/dist/chunk-S767XFOS.mjs.map +0 -1
- package/dist/chunk-SGSQKXDO.mjs.map +0 -1
- package/dist/chunk-TOLR2FNF.mjs.map +0 -1
- package/dist/chunk-UNX3KZO2.mjs.map +0 -1
- package/dist/chunk-UZP4YX7I.mjs.map +0 -1
- package/dist/chunk-VACGGQOL.mjs.map +0 -1
- package/dist/chunk-VAKCSKGR.mjs.map +0 -1
- package/dist/chunk-VJGGYY4Y.mjs.map +0 -1
- package/dist/chunk-WFQ3LAHQ.mjs.map +0 -1
- package/dist/chunk-XS4ZPJMT.mjs.map +0 -1
- package/dist/chunk-XW452I77.mjs.map +0 -1
- package/dist/chunk-YMNXRH52.mjs.map +0 -1
- package/dist/chunk-Z4IO7EIH.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision: number = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";AAeO,SAAS,MAAM,OAAe,YAAoB,GAAW;AAClE,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/intersection.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: T[], secondArr: T[]): T[] {\n return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n"],"mappings":";AAiBO,SAAS,aAAgB,UAAe,WAAqB;AAClE,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,SAAS,IAAI;AAAA,EAChC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/promise/delay.ts"],"sourcesContent":["/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n */\nexport function delay(ms: number): Promise<void> {\n return new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n}\n"],"mappings":";AAkBO,SAAS,MAAM,IAA2B;AAC/C,SAAO,IAAI,QAAQ,aAAW;AAC5B,eAAW,SAAS,EAAE;AAAA,EACxB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/predicate/isNotNil.ts"],"sourcesContent":["/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n"],"mappings":";AAeO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;","names":[]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
4
4
|
* method to cancel any pending execution.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {F} func - The function to debounce.
|
|
7
7
|
* @param {number} debounceMs - The number of milliseconds to delay.
|
|
8
|
-
* @returns {
|
|
8
|
+
* @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* const debouncedFunction = debounce(() => {
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
* // Will not log anything as the previous call is canceled
|
|
19
19
|
* debouncedFunction.cancel();
|
|
20
20
|
*/
|
|
21
|
-
declare function debounce(
|
|
22
|
-
(): void;
|
|
21
|
+
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & {
|
|
23
22
|
cancel: () => void;
|
|
24
23
|
};
|
|
25
24
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
4
4
|
* method to cancel any pending execution.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {F} func - The function to debounce.
|
|
7
7
|
* @param {number} debounceMs - The number of milliseconds to delay.
|
|
8
|
-
* @returns {
|
|
8
|
+
* @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* const debouncedFunction = debounce(() => {
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
* // Will not log anything as the previous call is canceled
|
|
19
19
|
* debouncedFunction.cancel();
|
|
20
20
|
*/
|
|
21
|
-
declare function debounce(
|
|
22
|
-
(): void;
|
|
21
|
+
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & {
|
|
23
22
|
cancel: () => void;
|
|
24
23
|
};
|
|
25
24
|
|
|
@@ -25,12 +25,12 @@ __export(debounce_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(debounce_exports);
|
|
26
26
|
function debounce(func, debounceMs) {
|
|
27
27
|
let timeoutId = null;
|
|
28
|
-
const debounced = function() {
|
|
28
|
+
const debounced = function(...args) {
|
|
29
29
|
if (timeoutId != null) {
|
|
30
30
|
clearTimeout(timeoutId);
|
|
31
31
|
}
|
|
32
32
|
timeoutId = setTimeout(() => {
|
|
33
|
-
func();
|
|
33
|
+
func(...args);
|
|
34
34
|
}, debounceMs);
|
|
35
35
|
};
|
|
36
36
|
debounced.cancel = function() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n */\nexport function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & { cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, debounceMs);\n } as F & { cancel: () => void };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n };\n\n return debounced;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,SAA6C,MAAS,YAAgD;AACpH,MAAI,YAA4C;AAEhD,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/function/index.js
CHANGED
|
@@ -29,12 +29,12 @@ module.exports = __toCommonJS(function_exports);
|
|
|
29
29
|
// src/function/debounce.ts
|
|
30
30
|
function debounce(func, debounceMs) {
|
|
31
31
|
let timeoutId = null;
|
|
32
|
-
const debounced = function() {
|
|
32
|
+
const debounced = function(...args) {
|
|
33
33
|
if (timeoutId != null) {
|
|
34
34
|
clearTimeout(timeoutId);
|
|
35
35
|
}
|
|
36
36
|
timeoutId = setTimeout(() => {
|
|
37
|
-
func();
|
|
37
|
+
func(...args);
|
|
38
38
|
}, debounceMs);
|
|
39
39
|
};
|
|
40
40
|
debounced.cancel = function() {
|
|
@@ -63,11 +63,11 @@ function once(func) {
|
|
|
63
63
|
// src/function/throttle.ts
|
|
64
64
|
function throttle(func, throttleMs) {
|
|
65
65
|
let lastCallTime;
|
|
66
|
-
const throttledFunction = function() {
|
|
66
|
+
const throttledFunction = function(...args) {
|
|
67
67
|
const now = Date.now();
|
|
68
68
|
if (lastCallTime == null || now - lastCallTime >= throttleMs) {
|
|
69
69
|
lastCallTime = now;
|
|
70
|
-
func();
|
|
70
|
+
func(...args);
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
return throttledFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/once.ts","../../src/function/throttle.ts"],"sourcesContent":["export { debounce } from './debounce';\nexport { once } from './once';\nexport { throttle } from './throttle'
|
|
1
|
+
{"version":3,"sources":["../../src/function/index.ts","../../src/function/debounce.ts","../../src/function/once.ts","../../src/function/throttle.ts"],"sourcesContent":["export { debounce } from './debounce';\nexport { once } from './once';\nexport { throttle } from './throttle';\n","/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n */\nexport function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & { cancel: () => void } {\n let timeoutId: number | NodeJS.Timeout | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, debounceMs);\n } as F & { cancel: () => void };\n\n debounced.cancel = function () {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n };\n\n return debounced;\n}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number) {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoBO,SAAS,SAA6C,MAAS,YAAgD;AACpH,MAAI,YAA4C;AAEhD,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,aAAa,MAAM;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;ACxBO,SAAS,KAA0B,MAAY;AACpD,MAAI,SAAS;AACb,MAAI;AAEJ,SAAO,WAAY;AACjB,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,KAAK;AAEpB,aAAS;AACT,YAAQ;AAER,WAAO;AAAA,EACT;AACF;;;ACPO,SAAS,SAA6C,MAAS,YAAoB;AACxF,MAAI;AAEJ,QAAM,oBAAoB,YAAa,MAAqB;AAC1D,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../chunk-SYQTG4N4.mjs";
|
|
2
2
|
import {
|
|
3
3
|
debounce
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GELVVASW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
once
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-UFAA5WKR.mjs";
|
|
8
8
|
import {
|
|
9
9
|
throttle
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-XLO3QZVY.mjs";
|
|
11
11
|
import "../chunk-2MM5EJJX.mjs";
|
|
12
12
|
export {
|
|
13
13
|
debounce,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/once.ts"],"sourcesContent":["/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n
|
|
1
|
+
{"version":3,"sources":["../../src/function/once.ts"],"sourcesContent":["/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,KAA0B,MAAY;AACpD,MAAI,SAAS;AACb,MAAI;AAEJ,SAAO,WAAY;AACjB,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,KAAK;AAEpB,aAAS;AACT,YAAQ;AAER,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/function/once.mjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
4
4
|
* within the wait time will not trigger the execution of the original function.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {F} func - The function to throttle.
|
|
7
7
|
* @param {number} throttleMs - The number of milliseconds to throttle executions to.
|
|
8
|
-
* @returns {
|
|
8
|
+
* @returns {F} A new throttled function that accepts the same parameters as the original function.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* const throttledFunction = throttle(() => {
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
* throttledFunction(); // Will log 'Function executed'
|
|
24
24
|
* }, 1000);
|
|
25
25
|
*/
|
|
26
|
-
declare function throttle(
|
|
26
|
+
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F;
|
|
27
27
|
|
|
28
28
|
export { throttle };
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
4
4
|
* within the wait time will not trigger the execution of the original function.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {F} func - The function to throttle.
|
|
7
7
|
* @param {number} throttleMs - The number of milliseconds to throttle executions to.
|
|
8
|
-
* @returns {
|
|
8
|
+
* @returns {F} A new throttled function that accepts the same parameters as the original function.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* const throttledFunction = throttle(() => {
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
* throttledFunction(); // Will log 'Function executed'
|
|
24
24
|
* }, 1000);
|
|
25
25
|
*/
|
|
26
|
-
declare function throttle(
|
|
26
|
+
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F;
|
|
27
27
|
|
|
28
28
|
export { throttle };
|
|
@@ -25,11 +25,11 @@ __export(throttle_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(throttle_exports);
|
|
26
26
|
function throttle(func, throttleMs) {
|
|
27
27
|
let lastCallTime;
|
|
28
|
-
const throttledFunction = function() {
|
|
28
|
+
const throttledFunction = function(...args) {
|
|
29
29
|
const now = Date.now();
|
|
30
30
|
if (lastCallTime == null || now - lastCallTime >= throttleMs) {
|
|
31
31
|
lastCallTime = now;
|
|
32
|
-
func();
|
|
32
|
+
func(...args);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
return throttledFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/throttle.ts"],"sourcesContent":["/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../src/function/throttle.ts"],"sourcesContent":["/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number) {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,SAAS,SAA6C,MAAS,YAAoB;AACxF,MAAI;AAEJ,QAAM,oBAAoB,YAAa,MAAqB;AAC1D,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -99,9 +99,8 @@ function chunk(arr, size) {
|
|
|
99
99
|
|
|
100
100
|
// src/array/difference.ts
|
|
101
101
|
function difference(firstArr, secondArr) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
102
|
+
const secondSet = new Set(secondArr);
|
|
103
|
+
return firstArr.filter((item) => !secondSet.has(item));
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
// src/array/differenceBy.ts
|
|
@@ -345,12 +344,12 @@ function zipWith(arr1, ...rest) {
|
|
|
345
344
|
// src/function/debounce.ts
|
|
346
345
|
function debounce(func, debounceMs) {
|
|
347
346
|
let timeoutId = null;
|
|
348
|
-
const debounced = function() {
|
|
347
|
+
const debounced = function(...args) {
|
|
349
348
|
if (timeoutId != null) {
|
|
350
349
|
clearTimeout(timeoutId);
|
|
351
350
|
}
|
|
352
351
|
timeoutId = setTimeout(() => {
|
|
353
|
-
func();
|
|
352
|
+
func(...args);
|
|
354
353
|
}, debounceMs);
|
|
355
354
|
};
|
|
356
355
|
debounced.cancel = function() {
|
|
@@ -379,11 +378,11 @@ function once(func) {
|
|
|
379
378
|
// src/function/throttle.ts
|
|
380
379
|
function throttle(func, throttleMs) {
|
|
381
380
|
let lastCallTime;
|
|
382
|
-
const throttledFunction = function() {
|
|
381
|
+
const throttledFunction = function(...args) {
|
|
383
382
|
const now = Date.now();
|
|
384
383
|
if (lastCallTime == null || now - lastCallTime >= throttleMs) {
|
|
385
384
|
lastCallTime = now;
|
|
386
|
-
func();
|
|
385
|
+
func(...args);
|
|
387
386
|
}
|
|
388
387
|
};
|
|
389
388
|
return throttledFunction;
|