es-toolkit 1.2.2-dev.67 → 1.2.2-dev.70

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.
Files changed (44) hide show
  1. package/dist/array/index.js +2 -2
  2. package/dist/array/index.js.map +1 -1
  3. package/dist/array/index.mjs +4 -4
  4. package/dist/array/unionWith.js.map +1 -1
  5. package/dist/array/unionWith.mjs +2 -2
  6. package/dist/array/uniqBy.d.mts +5 -6
  7. package/dist/array/uniqBy.d.ts +5 -6
  8. package/dist/array/uniqBy.js +2 -2
  9. package/dist/array/uniqBy.js.map +1 -1
  10. package/dist/array/uniqBy.mjs +2 -2
  11. package/dist/array/uniqWith.d.mts +2 -3
  12. package/dist/array/uniqWith.d.ts +2 -3
  13. package/dist/array/uniqWith.js.map +1 -1
  14. package/dist/array/uniqWith.mjs +1 -1
  15. package/dist/array/xorWith.js.map +1 -1
  16. package/dist/array/xorWith.mjs +3 -3
  17. package/dist/{chunk-NXPEUTDI.mjs → chunk-2PFDLYQC.mjs} +1 -1
  18. package/dist/chunk-2PFDLYQC.mjs.map +1 -0
  19. package/dist/{chunk-5P2QE2VI.mjs → chunk-3KHI4I2X.mjs} +2 -2
  20. package/dist/chunk-ASFOKYTY.mjs +13 -0
  21. package/dist/chunk-ASFOKYTY.mjs.map +1 -0
  22. package/dist/{chunk-LVB7BYUY.mjs → chunk-FCF2RHPW.mjs} +2 -2
  23. package/dist/chunk-GOXQV6DX.mjs +33 -0
  24. package/dist/chunk-GOXQV6DX.mjs.map +1 -0
  25. package/dist/function/debounce.d.mts +18 -1
  26. package/dist/function/debounce.d.ts +18 -1
  27. package/dist/function/debounce.js +13 -3
  28. package/dist/function/debounce.js.map +1 -1
  29. package/dist/function/debounce.mjs +1 -1
  30. package/dist/function/index.js +13 -3
  31. package/dist/function/index.js.map +1 -1
  32. package/dist/function/index.mjs +4 -4
  33. package/dist/index.js +15 -5
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +22 -22
  36. package/dist/object/index.mjs +3 -3
  37. package/package.json +1 -1
  38. package/dist/chunk-GELVVASW.mjs +0 -23
  39. package/dist/chunk-GELVVASW.mjs.map +0 -1
  40. package/dist/chunk-LCYPY5SA.mjs +0 -13
  41. package/dist/chunk-LCYPY5SA.mjs.map +0 -1
  42. package/dist/chunk-NXPEUTDI.mjs.map +0 -1
  43. /package/dist/{chunk-5P2QE2VI.mjs.map → chunk-3KHI4I2X.mjs.map} +0 -0
  44. /package/dist/{chunk-LVB7BYUY.mjs.map → chunk-FCF2RHPW.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.2.2-dev.67+44e09c0b",
4
+ "version": "1.2.2-dev.70+a707c06f",
5
5
  "workspaces": [
6
6
  "docs"
7
7
  ],
@@ -1,23 +0,0 @@
1
- // src/function/debounce.ts
2
- function debounce(func, debounceMs) {
3
- let timeoutId = null;
4
- const debounced = function(...args) {
5
- if (timeoutId != null) {
6
- clearTimeout(timeoutId);
7
- }
8
- timeoutId = setTimeout(() => {
9
- func(...args);
10
- }, debounceMs);
11
- };
12
- debounced.cancel = function() {
13
- if (timeoutId != null) {
14
- clearTimeout(timeoutId);
15
- }
16
- };
17
- return debounced;
18
- }
19
-
20
- export {
21
- debounce
22
- };
23
- //# sourceMappingURL=chunk-GELVVASW.mjs.map
@@ -1 +0,0 @@
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":";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":[]}
@@ -1,13 +0,0 @@
1
- import {
2
- uniqWith
3
- } from "./chunk-NXPEUTDI.mjs";
4
-
5
- // src/array/uniqBy.ts
6
- function uniqBy(arr, converter) {
7
- return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));
8
- }
9
-
10
- export {
11
- uniqBy
12
- };
13
- //# sourceMappingURL=chunk-LCYPY5SA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/array/uniqBy.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * 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.\n *\n * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} converter - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the converter function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.3, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: readonly T[], converter: (item: T) => U): T[] {\n return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));\n}\n"],"mappings":";;;;;AAiBO,SAAS,OAAa,KAAmB,WAAgC;AAC9E,SAAO,SAAS,KAAK,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM,UAAU,KAAK,CAAC;AAC9E;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/array/uniqWith.ts"],"sourcesContent":["/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * 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.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";AAeO,SAAS,SAAY,KAAmB,eAAqD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}