es-toolkit 1.13.1-dev.339 → 1.13.1-dev.345

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 (43) hide show
  1. package/dist/browser.global.js +1 -1
  2. package/dist/browser.global.js.map +1 -1
  3. package/dist/compat/_internal/isArrayMatch.mjs +25 -0
  4. package/dist/compat/_internal/isArrayMatch.mjs.map +1 -0
  5. package/dist/compat/_internal/isMapMatch.mjs +19 -0
  6. package/dist/compat/_internal/isMapMatch.mjs.map +1 -0
  7. package/dist/compat/_internal/isSetMatch.mjs +14 -0
  8. package/dist/compat/_internal/isSetMatch.mjs.map +1 -0
  9. package/dist/compat/index.d.mts +3 -0
  10. package/dist/compat/index.d.ts +3 -0
  11. package/dist/compat/index.js +108 -0
  12. package/dist/compat/index.js.map +1 -1
  13. package/dist/compat/index.mjs +3 -0
  14. package/dist/compat/index.mjs.map +1 -1
  15. package/dist/compat/predicate/isMatch.d.mts +31 -0
  16. package/dist/compat/predicate/isMatch.d.ts +31 -0
  17. package/dist/compat/predicate/isMatch.mjs +59 -0
  18. package/dist/compat/predicate/isMatch.mjs.map +1 -0
  19. package/dist/compat/predicate/matches.d.mts +27 -0
  20. package/dist/compat/predicate/matches.d.ts +27 -0
  21. package/dist/compat/predicate/matches.mjs +12 -0
  22. package/dist/compat/predicate/matches.mjs.map +1 -0
  23. package/dist/function/before.d.mts +31 -0
  24. package/dist/function/before.d.ts +31 -0
  25. package/dist/function/before.mjs +15 -0
  26. package/dist/function/before.mjs.map +1 -0
  27. package/dist/function/index.d.mts +1 -0
  28. package/dist/function/index.d.ts +1 -0
  29. package/dist/function/index.js +14 -0
  30. package/dist/function/index.js.map +1 -1
  31. package/dist/function/index.mjs +1 -0
  32. package/dist/function/index.mjs.map +1 -1
  33. package/dist/index.d.mts +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +1 -0
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/object/cloneDeep.mjs +6 -9
  40. package/dist/object/cloneDeep.mjs.map +1 -1
  41. package/dist/object/index.js +6 -9
  42. package/dist/object/index.js.map +1 -1
  43. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Creates a function that performs a deep comparison between a given target and the source object.
3
+ *
4
+ * @param {unknown} source - The source object to create the matcher from.
5
+ * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.
6
+ *
7
+ * @example
8
+ * // Basic usage
9
+ * const matcher = matches({ a: 1, b: 2 });
10
+ * matcher({ a: 1, b: 2, c: 3 }); // true
11
+ * matcher({ a: 1, c: 3 }); // false
12
+ *
13
+ * @example
14
+ * // Matching arrays
15
+ * const arrayMatcher = matches([1, 2, 3]);
16
+ * arrayMatcher([1, 2, 3, 4]); // true
17
+ * arrayMatcher([4, 5, 6]); // false
18
+ *
19
+ * @example
20
+ * // Matching objects with nested structures
21
+ * const nestedMatcher = matches({ a: { b: 2 } });
22
+ * nestedMatcher({ a: { b: 2, c: 3 } }); // true
23
+ * nestedMatcher({ a: { c: 3 } }); // false
24
+ */
25
+ declare function matches(source: unknown): (target: unknown) => boolean;
26
+
27
+ export { matches };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Creates a function that performs a deep comparison between a given target and the source object.
3
+ *
4
+ * @param {unknown} source - The source object to create the matcher from.
5
+ * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.
6
+ *
7
+ * @example
8
+ * // Basic usage
9
+ * const matcher = matches({ a: 1, b: 2 });
10
+ * matcher({ a: 1, b: 2, c: 3 }); // true
11
+ * matcher({ a: 1, c: 3 }); // false
12
+ *
13
+ * @example
14
+ * // Matching arrays
15
+ * const arrayMatcher = matches([1, 2, 3]);
16
+ * arrayMatcher([1, 2, 3, 4]); // true
17
+ * arrayMatcher([4, 5, 6]); // false
18
+ *
19
+ * @example
20
+ * // Matching objects with nested structures
21
+ * const nestedMatcher = matches({ a: { b: 2 } });
22
+ * nestedMatcher({ a: { b: 2, c: 3 } }); // true
23
+ * nestedMatcher({ a: { c: 3 } }); // false
24
+ */
25
+ declare function matches(source: unknown): (target: unknown) => boolean;
26
+
27
+ export { matches };
@@ -0,0 +1,12 @@
1
+ import { cloneDeep } from '../../object/cloneDeep.mjs';
2
+ import { isMatch } from './isMatch.mjs';
3
+
4
+ function matches(source) {
5
+ source = cloneDeep(source);
6
+ return (target) => {
7
+ return isMatch(target, source);
8
+ };
9
+ }
10
+
11
+ export { matches };
12
+ //# sourceMappingURL=matches.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matches.mjs","sources":["../../../src/compat/predicate/matches.ts"],"sourcesContent":["import { cloneDeep } from '../../object/cloneDeep.ts';\nimport { isMatch } from './isMatch.ts';\n\n/**\n * Creates a function that performs a deep comparison between a given target and the source object.\n * \n * @param {unknown} source - The source object to create the matcher from.\n * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * const matcher = matches({ a: 1, b: 2 });\n * matcher({ a: 1, b: 2, c: 3 }); // true\n * matcher({ a: 1, c: 3 }); // false\n *\n * @example\n * // Matching arrays\n * const arrayMatcher = matches([1, 2, 3]);\n * arrayMatcher([1, 2, 3, 4]); // true\n * arrayMatcher([4, 5, 6]); // false\n *\n * @example\n * // Matching objects with nested structures\n * const nestedMatcher = matches({ a: { b: 2 } });\n * nestedMatcher({ a: { b: 2, c: 3 } }); // true\n * nestedMatcher({ a: { c: 3 } }); // false\n */\nexport function matches(source: unknown): (target: unknown) => boolean {\n source = cloneDeep(source);\n\n return (target?: unknown): boolean => {\n return isMatch(target, source);\n };\n}\n"],"names":[],"mappings":";;;AA2BM,SAAU,OAAO,CAAC,MAAe,EAAA;AACrC,IAAA,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAE3B,OAAO,CAAC,MAAgB,KAAa;AACnC,QAAA,OAAO,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjC,KAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a function that limits the number of times the given function (`func`) can be called.
3
+ *
4
+ * @template F - The type of the function to be invoked.
5
+ * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.
6
+ * - If `n` is 0, `func` will never be called.
7
+ * - If `n` is a positive integer, `func` will be called up to `n-1` times.
8
+ * @param {F} func - The function to be called with the limit applied.
9
+ * @returns {F} - A new function that:
10
+ * - Tracks the number of calls.
11
+ * - Invokes `func` until the `n-1`-th call.
12
+ * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.
13
+ * @throws {Error} - Throw an error if `n` is negative.
14
+ * @example
15
+ *
16
+ * const beforeFn = before(3, () => {
17
+ * console.log("called");
18
+ * })
19
+ *
20
+ * // Will log 'called'.
21
+ * beforeFn();
22
+ *
23
+ * // Will log 'called'.
24
+ * beforeFn();
25
+ *
26
+ * // Will not log anything.
27
+ * beforeFn();
28
+ */
29
+ declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
30
+
31
+ export { before };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a function that limits the number of times the given function (`func`) can be called.
3
+ *
4
+ * @template F - The type of the function to be invoked.
5
+ * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.
6
+ * - If `n` is 0, `func` will never be called.
7
+ * - If `n` is a positive integer, `func` will be called up to `n-1` times.
8
+ * @param {F} func - The function to be called with the limit applied.
9
+ * @returns {F} - A new function that:
10
+ * - Tracks the number of calls.
11
+ * - Invokes `func` until the `n-1`-th call.
12
+ * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.
13
+ * @throws {Error} - Throw an error if `n` is negative.
14
+ * @example
15
+ *
16
+ * const beforeFn = before(3, () => {
17
+ * console.log("called");
18
+ * })
19
+ *
20
+ * // Will log 'called'.
21
+ * beforeFn();
22
+ *
23
+ * // Will log 'called'.
24
+ * beforeFn();
25
+ *
26
+ * // Will not log anything.
27
+ * beforeFn();
28
+ */
29
+ declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
30
+
31
+ export { before };
@@ -0,0 +1,15 @@
1
+ const before = (n, func) => {
2
+ if (!Number.isInteger(n) || n < 0) {
3
+ throw new Error('n must be a non-negative integer.');
4
+ }
5
+ let counter = 0;
6
+ return ((...args) => {
7
+ if (++counter < n) {
8
+ return func(...args);
9
+ }
10
+ return undefined;
11
+ });
12
+ };
13
+
14
+ export { before };
15
+ //# sourceMappingURL=before.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"before.mjs","sources":["../../src/function/before.ts"],"sourcesContent":["/**\n * Creates a function that limits the number of times the given function (`func`) can be called.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.\n * - If `n` is 0, `func` will never be called.\n * - If `n` is a positive integer, `func` will be called up to `n-1` times.\n * @param {F} func - The function to be called with the limit applied.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` until the `n-1`-th call.\n * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.\n * @throws {Error} - Throw an error if `n` is negative.\n * @example\n *\n * const beforeFn = before(3, () => {\n * console.log(\"called\");\n * })\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will not log anything.\n * beforeFn();\n */\n\nexport const before = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error('n must be a non-negative integer.');\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter < n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n"],"names":[],"mappings":"MA6Ba,MAAM,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AACjF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE;AACjB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;;;"}
@@ -1,3 +1,4 @@
1
+ export { before } from './before.mjs';
1
2
  export { after } from './after.mjs';
2
3
  export { debounce } from './debounce.mjs';
3
4
  export { noop } from './noop.mjs';
@@ -1,3 +1,4 @@
1
+ export { before } from './before.js';
1
2
  export { after } from './after.js';
2
3
  export { debounce } from './debounce.js';
3
4
  export { noop } from './noop.js';
@@ -2,6 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
+ const before = (n, func) => {
6
+ if (!Number.isInteger(n) || n < 0) {
7
+ throw new Error('n must be a non-negative integer.');
8
+ }
9
+ let counter = 0;
10
+ return ((...args) => {
11
+ if (++counter < n) {
12
+ return func(...args);
13
+ }
14
+ return undefined;
15
+ });
16
+ };
17
+
5
18
  const after = (n, func) => {
6
19
  if (!Number.isInteger(n) || n < 0) {
7
20
  throw new Error(`n must be a non-negative integer.`);
@@ -75,6 +88,7 @@ function negate(func) {
75
88
  }
76
89
 
77
90
  exports.after = after;
91
+ exports.before = before;
78
92
  exports.debounce = debounce;
79
93
  exports.negate = negate;
80
94
  exports.noop = noop;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\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 * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\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 *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) ;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\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 * @template F - The type of function.\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 * @template F - The type of function.\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): F {\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","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"names":[],"mappings":";;;;MA6Ba,KAAK,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AAChF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,CAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE;AAClB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;ACFM,SAAU,QAAQ,CACtB,IAAO,EACP,UAAkB,EAClB,EAAE,MAAM,EAAA,GAAsB,EAAE,EAAA;IAEhC,IAAI,SAAS,GAAyC,IAAI,CAAC;AAE3D,IAAA,MAAM,SAAS,GAAG,UAAU,GAAG,IAAmB,EAAA;AAChD,QAAA,IAAI,SAAS,KAAK,IAAI,EAAE;YACtB,YAAY,CAAC,SAAS,CAAC,CAAC;SACzB;AAED,QAAA,IAAI,MAAM,EAAE,OAAO,EAAE;YACnB,OAAO;SACR;AA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AG,CAAC;AACnB,YAAA,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACf;AACH,KAAM,CAAC;AAEP,IAAA,OAAO,iBAAiB,CAAC;AAC3B;;AChCM,SAAU,MAAM,CAA4C,IAAO,EAAA;AACrE,IAAA,QAAQ,CAAC,GAAG,IAAW,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAO;AACrD;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/function/before.ts","../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["/**\n * Creates a function that limits the number of times the given function (`func`) can be called.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.\n * - If `n` is 0, `func` will never be called.\n * - If `n` is a positive integer, `func` will be called up to `n-1` times.\n * @param {F} func - The function to be called with the limit applied.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` until the `n-1`-th call.\n * - Returns `undefined` if the number of calls reaches or exceeds `n`, stopping further calls.\n * @throws {Error} - Throw an error if `n` is negative.\n * @example\n *\n * const beforeFn = before(3, () => {\n * console.log(\"called\");\n * })\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will log 'called'.\n * beforeFn();\n *\n * // Will not log anything.\n * beforeFn();\n */\n\nexport const before = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error('n must be a non-negative integer.');\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter < n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\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 * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\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 *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) ;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\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 * @template F - The type of function.\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 * @template F - The type of function.\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): F {\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","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"names":[],"mappings":";;;;MA6Ba,MAAM,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AACjF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE;AACjB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;;MCZa,KAAK,GAAG,CAAoC,CAAS,EAAE,IAAO,KAAO;AAChF,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,CAAmC,CAAC,CAAC;KACtD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,IAAA,QAAQ,CAAC,GAAG,IAAmB,KAAI;AACjC,QAAA,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE;AAClB,YAAA,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACtB;AACD,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,EAAO;AACV;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AAC;AAChB,KAAM,CAAC;AACT;;ACPgB,SAAA,QAAQ,CAAqC,IAAO,EAAE,UAAkB,EAAA;AACtF,IAAA,IAAI,YAA2B,CAAC;AAEhC,IAAA,MAAM,iBAAiB,GAAG,UAAU,GAAG,IAAmB,EAAA;AACxD,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,YAAY,IAAI,IAAI,IAAI,GAAG,GAAG,YAAY,IAAI,UAAU,EAAE;YAC5D,YAAY,GAAG,GAAG,CAAC;AACnB,YAAA,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACf;AACH,KAAM,CAAC;AAEP,IAAA,OAAO,iBAAiB,CAAC;AAC3B;;AChCM,SAAU,MAAM,CAA4C,IAAO,EAAA;AACrE,IAAA,QAAQ,CAAC,GAAG,IAAW,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAO;AACrD;;;;;;;;;;"}
@@ -1,3 +1,4 @@
1
+ export { before } from './before.mjs';
1
2
  export { after } from './after.mjs';
2
3
  export { debounce } from './debounce.mjs';
3
4
  export { noop } from './noop.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/dist/index.d.mts CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
52
  export { AbortError } from './error/AbortError.mjs';
53
53
  export { TimeoutError } from './error/TimeoutError.mjs';
54
+ export { before } from './function/before.mjs';
54
55
  export { after } from './function/after.mjs';
55
56
  export { debounce } from './function/debounce.mjs';
56
57
  export { noop } from './function/noop.mjs';
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.js';
51
51
  export { initial } from './array/initial.js';
52
52
  export { AbortError } from './error/AbortError.js';
53
53
  export { TimeoutError } from './error/TimeoutError.js';
54
+ export { before } from './function/before.js';
54
55
  export { after } from './function/after.js';
55
56
  export { debounce } from './function/debounce.js';
56
57
  export { noop } from './function/noop.js';
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ exports.TimeoutError = promise_index.TimeoutError;
71
71
  exports.delay = promise_index.delay;
72
72
  exports.withTimeout = promise_index.withTimeout;
73
73
  exports.after = function_index.after;
74
+ exports.before = function_index.before;
74
75
  exports.debounce = function_index.debounce;
75
76
  exports.negate = function_index.negate;
76
77
  exports.noop = function_index.noop;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -51,6 +51,7 @@ export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
52
  export { AbortError } from './error/AbortError.mjs';
53
53
  export { TimeoutError } from './error/TimeoutError.mjs';
54
+ export { before } from './function/before.mjs';
54
55
  export { after } from './function/after.mjs';
55
56
  export { debounce } from './function/debounce.mjs';
56
57
  export { noop } from './function/noop.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -65,21 +65,18 @@ function cloneDeep(obj) {
65
65
  cloneDeepHelper(obj, result);
66
66
  return result;
67
67
  }
68
- if (typeof obj === 'function') {
69
- return void 0;
70
- }
71
68
  return obj;
72
69
  }
73
70
  function isPrimitive(value) {
74
71
  return value == null || (typeof value !== 'object' && typeof value !== 'function');
75
72
  }
76
73
  function cloneDeepHelper(obj, clonedObj) {
77
- for (const key in obj) {
78
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
79
- const descriptor = Object.getOwnPropertyDescriptor(obj, key);
80
- if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== 'function') {
81
- clonedObj[key] = cloneDeep(obj[key]);
82
- }
74
+ const keys = Object.keys(obj);
75
+ for (let i = 0; i < keys.length; i++) {
76
+ const key = keys[i];
77
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
78
+ if ((descriptor?.writable || descriptor?.set)) {
79
+ clonedObj[key] = cloneDeep(obj[key]);
83
80
  }
84
81
  }
85
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cloneDeep.mjs","sources":["../../src/object/cloneDeep.ts"],"sourcesContent":["/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => cloneDeep(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeep(obj[i]);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)\n ) {\n return obj.slice(0) as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0));\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new (): Error })();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'function') {\n return void 0 as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n\n// eslint-disable-next-line\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== 'function') {\n clonedObj[key] = cloneDeep(obj[key]);\n }\n }\n }\n}\n\nfunction isTypedArray(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n\nexport type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> =\n T extends Array<infer U>\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : Array<ResolvedMain<U>>\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [never]\n ? false\n : T extends readonly any[]\n ? number extends T['length']\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O\n ? O extends IValueOf<infer Primitive>\n ? Instance extends Primitive\n ? false\n :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M,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC7D,YAAA,IAAI,CAAC,UAAU,EAAE,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE;gBACxF,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;aACtC;SACF;KACF;AACH,CAAC;AAED,SAAS,YAAY,CAEnB,GAAQ,EAAA;IAaR,QACE,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,iBAAiB;AAChC,QAAA,GAAG,YAAY,WAAW;AAC1B,QAAA,GAAG,YAAY,WAAW;AAC1B,QAAA,GAAG,YAAY,cAAc;AAC7B,QAAA,GAAG,YAAY,SAAS;AACxB,QAAA,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,aAAa;AAC5B,QAAA,GAAG,YAAY,YAAY;QAC3B,GAAG,YAAY,YAAY,EAC3B;AACJ;;;;"}
1
+ {"version":3,"file":"cloneDeep.mjs","sources":["../../src/object/cloneDeep.ts"],"sourcesContent":["/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => cloneDeep(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeep(obj[i]);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)\n ) {\n return obj.slice(0) as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0));\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new(): Error })();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n\n// eslint-disable-next-line\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n const keys = Object.keys(obj);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if ((descriptor?.writable || descriptor?.set)) {\n clonedObj[key] = cloneDeep(obj[key]);\n }\n }\n}\n\nfunction isTypedArray(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n\nexport type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> =\n T extends Array<infer U>\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : Array<ResolvedMain<U>>\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [never]\n ? false\n : T extends readonly any[]\n ? number extends T['length']\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O\n ? O extends IValueOf<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface IValueOf<T> {\n valueOf(): T;\n}\n"],"names":[],"mappings":"AA8CM,SAAU,SAAS,CAAI,GAAM,E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AAE,GAAG,GAAG;YAC7C,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACtC;KACF;AACH,CAAC;AAED,SAAS,YAAY,CAEnB,GAAQ,EAAA;IAaR,QACE,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,iBAAiB;AAChC,QAAA,GAAG,YAAY,WAAW;AAC1B,QAAA,GAAG,YAAY,WAAW;AAC1B,QAAA,GAAG,YAAY,cAAc;AAC7B,QAAA,GAAG,YAAY,SAAS;AACxB,QAAA,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,UAAU;AACzB,QAAA,GAAG,YAAY,aAAa;AAC5B,QAAA,GAAG,YAAY,YAAY;QAC3B,GAAG,YAAY,YAAY,EAC3B;AACJ;;;;"}
@@ -158,21 +158,18 @@ function cloneDeep(obj) {
158
158
  cloneDeepHelper(obj, result);
159
159
  return result;
160
160
  }
161
- if (typeof obj === 'function') {
162
- return void 0;
163
- }
164
161
  return obj;
165
162
  }
166
163
  function isPrimitive(value) {
167
164
  return value == null || (typeof value !== 'object' && typeof value !== 'function');
168
165
  }
169
166
  function cloneDeepHelper(obj, clonedObj) {
170
- for (const key in obj) {
171
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
172
- const descriptor = Object.getOwnPropertyDescriptor(obj, key);
173
- if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== 'function') {
174
- clonedObj[key] = cloneDeep(obj[key]);
175
- }
167
+ const keys = Object.keys(obj);
168
+ for (let i = 0; i < keys.length; i++) {
169
+ const key = keys[i];
170
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
171
+ if ((descriptor?.writable || descriptor?.set)) {
172
+ clonedObj[key] = cloneDeep(obj[key]);
176
173
  }
177
174
  }
178
175
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/object/omit.ts","../../src/object/omitBy.ts","../../src/object/pick.ts","../../src/object/pickBy.ts","../../src/object/invert.ts","../../src/object/clone.ts","../../src/object/cloneDeep.ts","../../src/object/flattenObject.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n","/**\n * Creates a new object composed of the properties that do not satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns false.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to omit properties from.\n * @param {(value: T[string], key: keyof T) => boolean} shouldOmit - A predicate function that determines\n * whether a property should be omitted. It takes the property's key and value as arguments and returns `true`\n * if the property should be omitted, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'omit', c: 3 };\n * const shouldOmit = (key, value) => typeof value === 'string';\n * const result = omitBy(obj, shouldOmit);\n * // result will be { a: 1, c: 3 }\n */\nexport function omitBy<T extends Record<string, any>>(\n obj: T,\n shouldOmit: (value: T[keyof T], key: keyof T) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (shouldOmit(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick<T, K>} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n */\nexport function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n\n for (const key of keys) {\n result[key] = obj[key];\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the properties that satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns true.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to pick properties from.\n * @param {(value: T[keyof T], key: keyof T) => boolean} shouldPick - A predicate function that determines\n * whether a property should be picked. It takes the property's key and value as arguments and returns `true`\n * if the property should be picked, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'pick', c: 3 };\n * const shouldPick = (value) => typeof value === 'string';\n * const result = pickBy(obj, shouldPick);\n * // result will be { b: 'pick' }\n */\nexport function pickBy<T extends Record<string, any>>(\n obj: T,\n shouldPick: (value: T[keyof T], key: keyof T) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (!shouldPick(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n","/**\n * Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.\n *\n * This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,\n * the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping\n * of the input object's key-value pairs.\n *\n * @template K - Type of the keys in the input object (string, number, symbol)\n * @template V - Type of the values in the input object (string, number, symbol)\n * @param {Record<K, V>} obj - The input object whose keys and values are to be inverted\n * @returns {{ [key in V]: K }} - A new object with keys and values inverted\n *\n * @example\n * invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }\n * invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }\n * invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }\n * invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }\n */\nexport function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): { [key in V]: K } {\n const result = {} as { [key in V]: K };\n\n const keys = Object.keys(obj) as K[];\n \n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n result[value] = key;\n }\n\n return result;\n}\n","/**\n * Creates a shallow clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A shallow clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n */\nexport function clone<T>(obj: T): T {\n if (isPrimitive(obj)) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.slice() as T;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as T;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj) {\n result.set(key, value);\n }\n return result as T;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj) {\n result.add(value);\n }\n return result as T;\n }\n\n if (typeof obj === 'object') {\n const prototype = Object.getPrototypeOf(obj);\n const result = Object.create(prototype)\n return Object.assign(result, obj);\n }\n return obj;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n","/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => cloneDeep(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeep(obj[i]);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)\n ) {\n return obj.slice(0) as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0));\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new (): Error })();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'function') {\n return void 0 as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n\n// eslint-disable-next-line\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== 'function') {\n clonedObj[key] = cloneDeep(obj[key]);\n }\n }\n }\n}\n\nfunction isTypedArray(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n\nexport type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> =\n T extends Array<infer U>\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : Array<ResolvedMain<U>>\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [never]\n ? false\n : T extends readonly any[]\n ? number extends T['length']\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O\n ? O extends IValueOf<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface IValueOf<T> {\n valueOf(): T;\n}\n","import { isPlainObject } from \"../predicate/isPlainObject.ts\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n * \n * @param {object} object - The object to flatten.\n * @returns {Record<string, any>} - The flattened object.\n * \n * @example\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n * \n * const flattened = flattenObject(nestedObject);\n * console.log(flattened); \n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n */\nexport function flattenObject(object: object): Record<string, any> {\n return flattenObjectImpl(object);\n}\n\nfunction flattenObjectImpl(object: object, prefix = ''): Record<string, any> {\n const result: Record<string, any> = {};\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(result, flattenObjectImpl(value, prefixedKey));\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n result[`${prefixedKey}.${index}`] = value[index];\n }\n continue;\n }\n\n result[prefixedKey] = value;\n }\n\n return result;\n}"],"names":["isPrimitive","isPlainObject"],"mappings":";;;;;;AAiBgB,SAAA,IAAI,CAAmD,GAAM,EAAE,IAAS,EAAA;AACtF,IAAA,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;AAE1B,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACtB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACpB;AAED,IAAA,OAAO,MAAoB,CAAC;AAC9B;;ACNgB,SAAA,MAAM,CACpB,GAAM,EACN,UAAwD,EAAA;IAExD,MAAM,MAAM,GAAe,EAAE,CAAC;AAE9B,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,QAAA,IAAI,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAC1B,SAAS;SACV;AAEA,QAAA,MAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KAC9B;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;ACjBgB,SAAA,IAAI,CAAmD,GAAM,EAAE,IAAS,EAAA;IACtF,MAAM,MAAM,GAAG,EAAgB,CAAC;AAEhC,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;KACxB;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;ACNgB,SAAA,MAAM,CACpB,GAAM,EACN,UAAwD,EAAA;IAExD,MAAM,MAAM,GAAe,EAAE,CAAC;AAE9B,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAA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,EAAE;AACjD,gBAAA,MAAM,CAAC,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;aAClD;YACD,SAAS;SACV;AAED,QAAA,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;KAC7B;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/object/omit.ts","../../src/object/omitBy.ts","../../src/object/pick.ts","../../src/object/pickBy.ts","../../src/object/invert.ts","../../src/object/clone.ts","../../src/object/cloneDeep.ts","../../src/object/flattenObject.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n","/**\n * Creates a new object composed of the properties that do not satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns false.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to omit properties from.\n * @param {(value: T[string], key: keyof T) => boolean} shouldOmit - A predicate function that determines\n * whether a property should be omitted. It takes the property's key and value as arguments and returns `true`\n * if the property should be omitted, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'omit', c: 3 };\n * const shouldOmit = (key, value) => typeof value === 'string';\n * const result = omitBy(obj, shouldOmit);\n * // result will be { a: 1, c: 3 }\n */\nexport function omitBy<T extends Record<string, any>>(\n obj: T,\n shouldOmit: (value: T[keyof T], key: keyof T) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (shouldOmit(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick<T, K>} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n */\nexport function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n\n for (const key of keys) {\n result[key] = obj[key];\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the properties that satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns true.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to pick properties from.\n * @param {(value: T[keyof T], key: keyof T) => boolean} shouldPick - A predicate function that determines\n * whether a property should be picked. It takes the property's key and value as arguments and returns `true`\n * if the property should be picked, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'pick', c: 3 };\n * const shouldPick = (value) => typeof value === 'string';\n * const result = pickBy(obj, shouldPick);\n * // result will be { b: 'pick' }\n */\nexport function pickBy<T extends Record<string, any>>(\n obj: T,\n shouldPick: (value: T[keyof T], key: keyof T) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (!shouldPick(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n","/**\n * Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.\n *\n * This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,\n * the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping\n * of the input object's key-value pairs.\n *\n * @template K - Type of the keys in the input object (string, number, symbol)\n * @template V - Type of the values in the input object (string, number, symbol)\n * @param {Record<K, V>} obj - The input object whose keys and values are to be inverted\n * @returns {{ [key in V]: K }} - A new object with keys and values inverted\n *\n * @example\n * invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }\n * invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }\n * invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }\n * invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }\n */\nexport function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): { [key in V]: K } {\n const result = {} as { [key in V]: K };\n\n const keys = Object.keys(obj) as K[];\n \n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n result[value] = key;\n }\n\n return result;\n}\n","/**\n * Creates a shallow clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A shallow clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n */\nexport function clone<T>(obj: T): T {\n if (isPrimitive(obj)) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.slice() as T;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as T;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj) {\n result.set(key, value);\n }\n return result as T;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj) {\n result.add(value);\n }\n return result as T;\n }\n\n if (typeof obj === 'object') {\n const prototype = Object.getPrototypeOf(obj);\n const result = Object.create(prototype)\n return Object.assign(result, obj);\n }\n return obj;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n","/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => cloneDeep(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(cloneDeep(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeep(obj[i]);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)\n ) {\n return obj.slice(0) as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0));\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new(): Error })();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n\n// eslint-disable-next-line\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n const keys = Object.keys(obj);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if ((descriptor?.writable || descriptor?.set)) {\n clonedObj[key] = cloneDeep(obj[key]);\n }\n }\n}\n\nfunction isTypedArray(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: any\n): obj is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n obj instanceof Uint8Array ||\n obj instanceof Uint8ClampedArray ||\n obj instanceof Uint16Array ||\n obj instanceof Uint32Array ||\n obj instanceof BigUint64Array ||\n obj instanceof Int8Array ||\n obj instanceof Int16Array ||\n obj instanceof Int32Array ||\n obj instanceof BigInt64Array ||\n obj instanceof Float32Array ||\n obj instanceof Float64Array\n );\n}\n\nexport type Resolved<T> = Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> =\n T extends Array<infer U>\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : Array<ResolvedMain<U>>\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [never]\n ? false\n : T extends readonly any[]\n ? number extends T['length']\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends IValueOf<any>> = Instance extends O\n ? O extends IValueOf<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface IValueOf<T> {\n valueOf(): T;\n}\n","import { isPlainObject } from \"../predicate/isPlainObject.ts\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n * \n * @param {object} object - The object to flatten.\n * @returns {Record<string, any>} - The flattened object.\n * \n * @example\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n * \n * const flattened = flattenObject(nestedObject);\n * console.log(flattened); \n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n */\nexport function flattenObject(object: object): Record<string, any> {\n return flattenObjectImpl(object);\n}\n\nfunction flattenObjectImpl(object: object, prefix = ''): Record<string, any> {\n const result: Record<string, any> = {};\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(result, flattenObjectImpl(value, prefixedKey));\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n result[`${prefixedKey}.${index}`] = value[index];\n }\n continue;\n }\n\n result[prefixedKey] = value;\n }\n\n return result;\n}"],"names":["isPrimitive","isPlainObject"],"mappings":";;;;;;AAiBgB,SAAA,IAAI,CAAmD,GAAM,EAAE,IAAS,EAAA;AACtF,IAAA,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;AAE1B,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;AACtB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACpB;AAED,IAAA,OAAO,MAAoB,CAAC;AAC9B;;ACNgB,SAAA,MAAM,CACpB,GAAM,EACN,UAAwD,EAAA;IAExD,MAAM,MAAM,GAAe,EAAE,CAAC;AAE9B,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,QAAA,IAAI,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAC1B,SAAS;SACV;AAEA,QAAA,MAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KAC9B;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;ACjBgB,SAAA,IAAI,CAAmD,GAAM,EAAE,IAAS,EAAA;IACtF,MAAM,MAAM,GAAG,EAAgB,CAAC;AAEhC,IAAA,KAAK,MA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AC,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;YAC7D,SAAS;SACV;AAED,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;AACjD,gBAAA,MAAM,CAAC,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;aAClD;YACD,SAAS;SACV;AAED,QAAA,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;KAC7B;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;"}
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.13.1-dev.339+e262fa1b",
4
+ "version": "1.13.1-dev.345+0c6f7c95",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {