es-toolkit 1.10.1-dev.230 → 1.10.1-dev.237
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/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +73 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +4 -1
- package/dist/chunk-MKCRW4QT.mjs +80 -0
- package/dist/chunk-MKCRW4QT.mjs.map +1 -0
- package/dist/compat/index.d.mts +31 -1
- package/dist/compat/index.d.ts +31 -1
- package/dist/compat/index.js +75 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +6 -1
- package/dist/compat/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/zipObjectDeep-eeZxUsAU.d.mts +37 -0
- package/dist/zipObjectDeep-eeZxUsAU.d.ts +37 -0
- package/package.json +1 -1
- package/dist/chunk-DDH7K4QM.mjs +0 -1
- package/dist/chunk-DDH7K4QM.mjs.map +0 -1
package/dist/compat/index.mjs
CHANGED
|
@@ -83,7 +83,10 @@ import {
|
|
|
83
83
|
import {
|
|
84
84
|
inRange
|
|
85
85
|
} from "../chunk-BH6HLGBA.mjs";
|
|
86
|
-
import
|
|
86
|
+
import {
|
|
87
|
+
set,
|
|
88
|
+
zipObjectDeep
|
|
89
|
+
} from "../chunk-MKCRW4QT.mjs";
|
|
87
90
|
import {
|
|
88
91
|
xor
|
|
89
92
|
} from "../chunk-L7FQX5MN.mjs";
|
|
@@ -332,6 +335,7 @@ export {
|
|
|
332
335
|
round,
|
|
333
336
|
sample,
|
|
334
337
|
sampleSize,
|
|
338
|
+
set,
|
|
335
339
|
shuffle,
|
|
336
340
|
snakeCase,
|
|
337
341
|
startCase,
|
|
@@ -358,6 +362,7 @@ export {
|
|
|
358
362
|
xorWith,
|
|
359
363
|
zip,
|
|
360
364
|
zipObject,
|
|
365
|
+
zipObjectDeep,
|
|
361
366
|
zipWith
|
|
362
367
|
};
|
|
363
368
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAASA,OAAS,KAAmB,OAAe,GAAU;AACnE,SAAO,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC;AAEnC,MAAI,SAAS,GAAG;AACd,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAa,KAAK,IAAI;AAC/B;","names":["chunk"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -42,6 +42,7 @@ export { xorBy } from './array/xorBy.mjs';
|
|
|
42
42
|
export { xorWith } from './array/xorWith.mjs';
|
|
43
43
|
export { zip } from './array/zip.mjs';
|
|
44
44
|
export { zipObject } from './array/zipObject.mjs';
|
|
45
|
+
export { z as zipObjectDeep } from './zipObjectDeep-eeZxUsAU.mjs';
|
|
45
46
|
export { zipWith } from './array/zipWith.mjs';
|
|
46
47
|
export { without } from './array/without.mjs';
|
|
47
48
|
export { head } from './array/head.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { xorBy } from './array/xorBy.js';
|
|
|
42
42
|
export { xorWith } from './array/xorWith.js';
|
|
43
43
|
export { zip } from './array/zip.js';
|
|
44
44
|
export { zipObject } from './array/zipObject.js';
|
|
45
|
+
export { z as zipObjectDeep } from './zipObjectDeep-eeZxUsAU.js';
|
|
45
46
|
export { zipWith } from './array/zipWith.js';
|
|
46
47
|
export { without } from './array/without.js';
|
|
47
48
|
export { head } from './array/head.js';
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,7 @@ __export(src_exports, {
|
|
|
118
118
|
xorWith: () => xorWith,
|
|
119
119
|
zip: () => zip,
|
|
120
120
|
zipObject: () => zipObject,
|
|
121
|
+
zipObjectDeep: () => zipObjectDeep,
|
|
121
122
|
zipWith: () => zipWith
|
|
122
123
|
});
|
|
123
124
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -580,6 +581,77 @@ function zipObject(keys, values) {
|
|
|
580
581
|
return result;
|
|
581
582
|
}
|
|
582
583
|
|
|
584
|
+
// src/compat/_internal/isIndex.ts
|
|
585
|
+
var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
586
|
+
function isIndex(value) {
|
|
587
|
+
switch (typeof value) {
|
|
588
|
+
case "number": {
|
|
589
|
+
return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
590
|
+
}
|
|
591
|
+
case "symbol": {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
case "string": {
|
|
595
|
+
return IS_UNSIGNED_INTEGER.test(value);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/compat/_internal/toPath.ts
|
|
601
|
+
var ESCAPE_REGEXP = /\\(\\)?/g;
|
|
602
|
+
var PROPERTY_REGEXP = RegExp(
|
|
603
|
+
// Match anything that isn't a dot or bracket.
|
|
604
|
+
`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
|
|
605
|
+
"g"
|
|
606
|
+
);
|
|
607
|
+
function toPath(deepKey) {
|
|
608
|
+
const result = [];
|
|
609
|
+
if (deepKey[0] === ".") {
|
|
610
|
+
result.push("");
|
|
611
|
+
}
|
|
612
|
+
let match;
|
|
613
|
+
while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
|
|
614
|
+
let [key, expr, quote, substr] = match;
|
|
615
|
+
if (quote) {
|
|
616
|
+
key = substr.replace(ESCAPE_REGEXP, "$1");
|
|
617
|
+
} else if (expr) {
|
|
618
|
+
key = expr.trim();
|
|
619
|
+
}
|
|
620
|
+
result.push(key);
|
|
621
|
+
}
|
|
622
|
+
return result;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// src/compat/object/set.ts
|
|
626
|
+
function set(obj, path, value) {
|
|
627
|
+
const resolvedPath = Array.isArray(path) ? path : typeof path === "string" ? toPath(path) : [path];
|
|
628
|
+
let current = obj;
|
|
629
|
+
for (let i = 0; i < resolvedPath.length - 1; i++) {
|
|
630
|
+
const key = resolvedPath[i];
|
|
631
|
+
const nextKey = resolvedPath[i + 1];
|
|
632
|
+
if (current[key] == null) {
|
|
633
|
+
current[key] = isIndex(nextKey) ? [] : {};
|
|
634
|
+
}
|
|
635
|
+
current = current[key];
|
|
636
|
+
}
|
|
637
|
+
const lastKey = resolvedPath[resolvedPath.length - 1];
|
|
638
|
+
current[lastKey] = value;
|
|
639
|
+
return obj;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// src/compat/array/zipObjectDeep.ts
|
|
643
|
+
function zipObjectDeep(keys, values) {
|
|
644
|
+
const result = {};
|
|
645
|
+
const zipped = zip(keys, values);
|
|
646
|
+
for (let i = 0; i < zipped.length; i++) {
|
|
647
|
+
const [key, value] = zipped[i];
|
|
648
|
+
if (key != null) {
|
|
649
|
+
set(result, key, value);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return result;
|
|
653
|
+
}
|
|
654
|
+
|
|
583
655
|
// src/array/zipWith.ts
|
|
584
656
|
function zipWith(arr1, ...rest) {
|
|
585
657
|
const arrs = [arr1, ...rest.slice(0, -1)];
|
|
@@ -1094,6 +1166,7 @@ function startCase(str) {
|
|
|
1094
1166
|
xorWith,
|
|
1095
1167
|
zip,
|
|
1096
1168
|
zipObject,
|
|
1169
|
+
zipObjectDeep,
|
|
1097
1170
|
zipWith
|
|
1098
1171
|
});
|
|
1099
1172
|
//# sourceMappingURL=index.js.map
|