es-toolkit 1.9.0 → 1.10.0-dev.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/README.md +1 -1
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.mjs +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.d.mts +25 -0
- package/dist/array/flattenDeep.d.ts +25 -0
- package/dist/array/flattenDeep.js +52 -0
- package/dist/array/flattenDeep.js.map +1 -0
- package/dist/array/flattenDeep.mjs +9 -0
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.d.mts +4 -0
- package/dist/array/index.d.ts +4 -0
- package/dist/array/index.js +38 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +45 -29
- package/dist/array/initial.d.mts +26 -0
- package/dist/array/initial.d.ts +26 -0
- package/dist/array/initial.js +36 -0
- package/dist/array/initial.js.map +1 -0
- package/dist/array/initial.mjs +8 -0
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/last.d.mts +25 -0
- package/dist/array/last.d.ts +25 -0
- package/dist/array/last.js +33 -0
- package/dist/array/last.js.map +1 -0
- package/dist/array/last.mjs +8 -0
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/orderBy.mjs +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.mjs +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/toFilled.d.mts +33 -0
- package/dist/array/toFilled.d.ts +33 -0
- package/dist/array/toFilled.js +40 -0
- package/dist/array/toFilled.js.map +1 -0
- package/dist/array/toFilled.mjs +8 -0
- package/dist/array/union.mjs +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.mjs +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/array/without.mjs +1 -1
- package/dist/array/xor.mjs +1 -1
- package/dist/array/xorBy.mjs +1 -1
- package/dist/array/xorWith.mjs +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/chunk-236H5JZJ.mjs +1 -0
- package/dist/chunk-2HIMLZE3.mjs +46 -0
- package/dist/chunk-2HIMLZE3.mjs.map +1 -0
- package/dist/chunk-2MRZANXZ.mjs +1 -0
- package/dist/chunk-2MRZANXZ.mjs.map +1 -0
- package/dist/chunk-2SLTL4KL.mjs +13 -0
- package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
- package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
- package/dist/chunk-5IKVJGHO.mjs +14 -0
- package/dist/chunk-5IKVJGHO.mjs.map +1 -0
- package/dist/chunk-ASJF5D6C.mjs +1 -0
- package/dist/chunk-ASJF5D6C.mjs.map +1 -0
- package/dist/chunk-BOOQBJN2.mjs +9 -0
- package/dist/chunk-BOOQBJN2.mjs.map +1 -0
- package/dist/chunk-EYYZQFOP.mjs +14 -0
- package/dist/chunk-EYYZQFOP.mjs.map +1 -0
- package/dist/chunk-F3WCQQET.mjs +14 -0
- package/dist/chunk-F3WCQQET.mjs.map +1 -0
- package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
- package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
- package/dist/chunk-JYSV56US.mjs +41 -0
- package/dist/chunk-JYSV56US.mjs.map +1 -0
- package/dist/chunk-KPBQ7OUY.mjs +9 -0
- package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
- package/dist/chunk-ML727RRJ.mjs +13 -0
- package/dist/chunk-ML727RRJ.mjs.map +1 -0
- package/dist/chunk-NKLIE2OI.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs.map +1 -0
- package/dist/chunk-OP4OAKQJ.mjs +16 -0
- package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
- package/dist/chunk-OSOLEQLZ.mjs +1 -0
- package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
- package/dist/chunk-QKYYOLJ6.mjs +1 -0
- package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
- package/dist/chunk-U4JGKZ56.mjs +41 -0
- package/dist/chunk-U4JGKZ56.mjs.map +1 -0
- package/dist/chunk-U56ZOM7L.mjs +9 -0
- package/dist/chunk-U56ZOM7L.mjs.map +1 -0
- package/dist/chunk-WMM7TZLG.mjs +9 -0
- package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
- package/dist/chunk-WVQ7YVRK.mjs +11 -0
- package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
- package/dist/chunk-XGCYC4YA.mjs +5516 -0
- package/dist/chunk-XGCYC4YA.mjs.map +1 -0
- package/dist/chunk-XPSOKBRZ.mjs +12 -0
- package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
- package/dist/compat/index.d.mts +108 -0
- package/dist/compat/index.d.ts +108 -0
- package/dist/compat/index.js +6578 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/index.mjs +351 -0
- package/dist/compat/index.mjs.map +1 -0
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +7 -0
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +8 -4
- package/dist/function/negate.d.mts +10 -0
- package/dist/function/negate.d.ts +10 -0
- package/dist/function/negate.js +33 -0
- package/dist/function/negate.js.map +1 -0
- package/dist/function/negate.mjs +8 -0
- package/dist/function/negate.mjs.map +1 -0
- package/dist/function/noop.mjs +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +5681 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -50
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.js +2 -2
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +9 -9
- package/dist/math/mean.js +2 -2
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +3 -3
- package/dist/math/meanBy.js +2 -2
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +4 -4
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.mjs +1 -1
- package/dist/math/range.mjs +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.js +2 -2
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +2 -2
- package/dist/object/clone.d.mts +31 -0
- package/dist/object/clone.d.ts +31 -0
- package/dist/object/clone.js +65 -0
- package/dist/object/clone.js.map +1 -0
- package/dist/object/clone.mjs +8 -0
- package/dist/object/clone.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +39 -0
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +7 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.mjs +2 -2
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +46 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +9 -3
- package/dist/predicate/isEqual.d.mts +17 -0
- package/dist/predicate/isEqual.d.ts +17 -0
- package/dist/predicate/isEqual.js +73 -0
- package/dist/predicate/isEqual.js.map +1 -0
- package/dist/predicate/isEqual.mjs +10 -0
- package/dist/predicate/isEqual.mjs.map +1 -0
- package/dist/predicate/isNil.js +1 -1
- package/dist/predicate/isNil.js.map +1 -1
- package/dist/predicate/isNil.mjs +2 -2
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.mjs +1 -1
- package/dist/string/camelCase.d.mts +17 -0
- package/dist/string/camelCase.d.ts +17 -0
- package/dist/string/camelCase.js +5554 -0
- package/dist/string/camelCase.js.map +1 -0
- package/dist/string/camelCase.mjs +9 -0
- package/dist/string/camelCase.mjs.map +1 -0
- package/dist/string/capitalize.d.mts +14 -0
- package/dist/string/capitalize.d.ts +14 -0
- package/dist/string/capitalize.js +33 -0
- package/dist/string/capitalize.js.map +1 -0
- package/dist/string/capitalize.mjs +8 -0
- package/dist/string/capitalize.mjs.map +1 -0
- package/dist/string/index.d.mts +5 -0
- package/dist/string/index.d.ts +5 -0
- package/dist/string/index.js +5587 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +26 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/kebabCase.d.mts +17 -0
- package/dist/string/kebabCase.d.ts +17 -0
- package/dist/string/kebabCase.js +43 -0
- package/dist/string/kebabCase.js.map +1 -0
- package/dist/string/kebabCase.mjs +9 -0
- package/dist/string/kebabCase.mjs.map +1 -0
- package/dist/string/lowerCase.d.mts +17 -0
- package/dist/string/lowerCase.d.ts +17 -0
- package/dist/string/lowerCase.js +43 -0
- package/dist/string/lowerCase.js.map +1 -0
- package/dist/string/lowerCase.mjs +9 -0
- package/dist/string/lowerCase.mjs.map +1 -0
- package/dist/string/snakeCase.d.mts +17 -0
- package/dist/string/snakeCase.d.ts +17 -0
- package/dist/string/snakeCase.js +43 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/snakeCase.mjs +9 -0
- package/dist/string/snakeCase.mjs.map +1 -0
- package/package.json +21 -1
- package/string.d.ts +1 -0
- package/dist/chunk-2MM5EJJX.mjs +0 -21
- package/dist/chunk-LOY6PATI.mjs +0 -1
- package/dist/chunk-MAJSPFA6.mjs +0 -1
- package/dist/chunk-N6EM6ETS.mjs +0 -1
- package/dist/chunk-NOFHNJ5C.mjs +0 -13
- package/dist/chunk-OHQAR5AU.mjs +0 -9
- package/dist/chunk-PMHULJNL.mjs +0 -1
- /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
- /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
- /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
- /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
- /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
- /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
- /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
- /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-ASJF5D6C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/function/negate.ts"],"sourcesContent":["/**\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"],"mappings":";AAOO,SAAS,OAAkD,MAAY;AAC1E,SAAQ,IAAI,SAAgB,CAAC,KAAK,GAAG,IAAI;AAC7C;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWords
|
|
3
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/kebabCase.ts
|
|
6
|
+
var kebabCase = (str) => {
|
|
7
|
+
const words = getWords(str);
|
|
8
|
+
return words.map((word) => word.toLowerCase()).join("-");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
kebabCase
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-EYYZQFOP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/kebabCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWords
|
|
3
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/snakeCase.ts
|
|
6
|
+
var snakeCase = (str) => {
|
|
7
|
+
const words = getWords(str);
|
|
8
|
+
return words.map((word) => word.toLowerCase()).join("_");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
snakeCase
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-F3WCQQET.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/snakeCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sum
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
4
4
|
|
|
5
5
|
// src/math/mean.ts
|
|
6
6
|
function mean(nums) {
|
|
@@ -10,4 +10,4 @@ function mean(nums) {
|
|
|
10
10
|
export {
|
|
11
11
|
mean
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-GDC64SYJ.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mean
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GDC64SYJ.mjs";
|
|
4
4
|
|
|
5
5
|
// src/math/meanBy.ts
|
|
6
6
|
function meanBy(items, getValue) {
|
|
@@ -11,4 +11,4 @@ function meanBy(items, getValue) {
|
|
|
11
11
|
export {
|
|
12
12
|
meanBy
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-IZAD2S7R.mjs.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
union
|
|
3
|
+
} from "./chunk-R6QA7PLZ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/predicate/isEqual.ts
|
|
6
|
+
function isEqual(a, b) {
|
|
7
|
+
if (Object.is(a, b)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (a instanceof Date && b instanceof Date) {
|
|
11
|
+
return a.getTime() === b.getTime();
|
|
12
|
+
}
|
|
13
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
14
|
+
return a.source === b.source && a.flags === b.flags;
|
|
15
|
+
}
|
|
16
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const aKeys = Object.keys(a);
|
|
20
|
+
const bKeys = Object.keys(b);
|
|
21
|
+
if (aKeys.length !== bKeys.length) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (union(aKeys, bKeys).length !== aKeys.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
28
|
+
const propKey = aKeys[i];
|
|
29
|
+
const aProp = a[propKey];
|
|
30
|
+
const bProp = b[propKey];
|
|
31
|
+
if (!isEqual(aProp, bProp)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
isEqual
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-JYSV56US.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/predicate/isEqual.ts"],"sourcesContent":["import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;;AAgBO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EACnC;AAEA,MAAI,aAAa,UAAU,aAAa,QAAQ;AAC9C,WAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAAA,EAChD;AAEA,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC9E,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,KAAK,CAAW;AACrC,QAAM,QAAQ,OAAO,KAAK,CAAW;AAErC,MAAI,MAAM,WAAW,MAAM,QAAQ;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,OAAO,KAAK,EAAE,WAAW,MAAM,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,MAAM,CAAC;AACvB,UAAM,QAAS,EAAU,OAAO;AAChC,UAAM,QAAS,EAAU,OAAO;AAEhC,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/last.ts"],"sourcesContent":["/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\n\nexport function last<T>(arr: readonly [...T[], T]): T;\nexport function last<T>(arr: readonly T[]): T | undefined;\nexport function last<T>(arr: readonly T[]): T | undefined {\n return arr[arr.length - 1];\n}\n"],"mappings":";AAwBO,SAAS,KAAQ,KAAkC;AACxD,SAAO,IAAI,IAAI,SAAS,CAAC;AAC3B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/flattenDeep.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Utility type for recursively unpacking nested array types to extract the type of the innermost element\n *\n * @example\n * ExtractNestedArrayType<(number | (number | number[])[])[]>\n * // number\n *\n * ExtractNestedArrayType<(boolean | (string | number[])[])[]>\n * // string | number | boolean\n */\ntype ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;\n\n/**\n * Flattens all depths of a nested array.\n *\n * @template T - The type of elements within the array.\n * @param {T[]} arr - The array to flatten.\n * @returns {Array<ExtractNestedArrayType<T>>} A new array that has been flattened.\n *\n * @example\n * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>> {\n return flatten(arr, Infinity) as Array<ExtractNestedArrayType<T>>;\n}\n"],"mappings":";;;;;AAyBO,SAAS,YAAe,KAAqD;AAClF,SAAO,QAAQ,KAAK,QAAQ;AAC9B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-NKLIE2OI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/array/toFilled.ts
|
|
2
|
+
function toFilled(arr, value, start = 0, end = arr.length) {
|
|
3
|
+
const length = arr.length;
|
|
4
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
5
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
6
|
+
const newArr = arr.slice();
|
|
7
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
8
|
+
newArr[i] = value;
|
|
9
|
+
}
|
|
10
|
+
return newArr;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
toFilled
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-OP4OAKQJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";AAgCO,SAAS,SAAe,KAAU,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AAC5F,QAAM,SAAS,IAAI;AACnB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,QAAM,SAAuB,IAAI,MAAM;AAEvC,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,WAAO,CAAC,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-OSOLEQLZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-QKYYOLJ6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/object/clone.ts
|
|
2
|
+
function clone(obj) {
|
|
3
|
+
if (isPrimitive(obj)) {
|
|
4
|
+
return obj;
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(obj)) {
|
|
7
|
+
return obj.slice();
|
|
8
|
+
}
|
|
9
|
+
if (obj instanceof Date) {
|
|
10
|
+
return new Date(obj.getTime());
|
|
11
|
+
}
|
|
12
|
+
if (obj instanceof RegExp) {
|
|
13
|
+
return new RegExp(obj.source, obj.flags);
|
|
14
|
+
}
|
|
15
|
+
if (obj instanceof Map) {
|
|
16
|
+
const result = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const [key, value] of obj) {
|
|
18
|
+
result.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
if (obj instanceof Set) {
|
|
23
|
+
const result = /* @__PURE__ */ new Set();
|
|
24
|
+
for (const value of obj) {
|
|
25
|
+
result.add(value);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
if (typeof obj === "object") {
|
|
30
|
+
return Object.assign({}, obj);
|
|
31
|
+
}
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
function isPrimitive(value) {
|
|
35
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
clone
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-U4JGKZ56.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object/clone.ts"],"sourcesContent":["/**\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 return Object.assign({}, obj) as T;\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 ||\n (typeof value !== \"object\" && typeof value !== \"function\");\n}\n"],"mappings":";AA4BO,SAAS,MAAS,KAAW;AAClC,MAAI,YAAY,GAAG,GAAG;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,MAAM;AAAA,EACnB;AAEA,MAAI,eAAe,MAAM;AACvB,WAAO,IAAI,KAAK,IAAI,QAAQ,CAAC;AAAA,EAC/B;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK;AAAA,EACzC;AAEA,MAAI,eAAe,KAAK;AACtB,UAAM,SAAS,oBAAI,IAAI;AACvB,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK;AAC9B,aAAO,IAAI,KAAK,KAAK;AAAA,IACvB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,KAAK;AACtB,UAAM,SAAS,oBAAI,IAAI;AACvB,eAAW,SAAS,KAAK;AACvB,aAAO,IAAI,KAAK;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,OAAO,OAAO,CAAC,GAAG,GAAG;AAAA,EAC9B;AACA,SAAO;AACT;AAIA,SAAS,YAAY,OAAoC;AACvD,SAAO,SAAS,QACb,OAAO,UAAU,YAAY,OAAO,UAAU;AACnD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/capitalize.ts"],"sourcesContent":["/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n"],"mappings":";AAYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/predicate/isNil.ts"],"sourcesContent":["/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x
|
|
1
|
+
{"version":3,"sources":["../src/predicate/isNil.ts"],"sourcesContent":["/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n"],"mappings":";AAmBO,SAAS,MAAM,GAAmC;AACvD,SAAO,KAAK;AACd;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/string/_internal/getWords.ts
|
|
2
|
+
var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
|
|
3
|
+
function getWords(str) {
|
|
4
|
+
var _a;
|
|
5
|
+
return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
getWords
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-WVQ7YVRK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/_internal/getWords.ts"],"sourcesContent":["/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";AAgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;","names":[]}
|