es-toolkit 1.10.1-dev.240 → 1.10.1-dev.242

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/index.mjs CHANGED
@@ -83,9 +83,7 @@ import {
83
83
  import {
84
84
  inRange
85
85
  } from "./chunk-BH6HLGBA.mjs";
86
- import {
87
- zipObjectDeep
88
- } from "./chunk-MKCRW4QT.mjs";
86
+ import "./chunk-DDH7K4QM.mjs";
89
87
  import {
90
88
  xor
91
89
  } from "./chunk-L7FQX5MN.mjs";
@@ -351,7 +349,6 @@ export {
351
349
  xorWith,
352
350
  zip,
353
351
  zipObject,
354
- zipObjectDeep,
355
352
  zipWith
356
353
  };
357
354
  //# sourceMappingURL=index.mjs.map
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.10.1-dev.240+d1e45482",
4
+ "version": "1.10.1-dev.242+964fdd36",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1,80 +0,0 @@
1
- import {
2
- zip
3
- } from "./chunk-IDCUZVJL.mjs";
4
-
5
- // src/compat/_internal/isIndex.ts
6
- var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
7
- function isIndex(value) {
8
- switch (typeof value) {
9
- case "number": {
10
- return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
11
- }
12
- case "symbol": {
13
- return false;
14
- }
15
- case "string": {
16
- return IS_UNSIGNED_INTEGER.test(value);
17
- }
18
- }
19
- }
20
-
21
- // src/compat/_internal/toPath.ts
22
- var ESCAPE_REGEXP = /\\(\\)?/g;
23
- var PROPERTY_REGEXP = RegExp(
24
- // Match anything that isn't a dot or bracket.
25
- `[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
26
- "g"
27
- );
28
- function toPath(deepKey) {
29
- const result = [];
30
- if (deepKey[0] === ".") {
31
- result.push("");
32
- }
33
- let match;
34
- while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
35
- let [key, expr, quote, substr] = match;
36
- if (quote) {
37
- key = substr.replace(ESCAPE_REGEXP, "$1");
38
- } else if (expr) {
39
- key = expr.trim();
40
- }
41
- result.push(key);
42
- }
43
- return result;
44
- }
45
-
46
- // src/compat/object/set.ts
47
- function set(obj, path, value) {
48
- const resolvedPath = Array.isArray(path) ? path : typeof path === "string" ? toPath(path) : [path];
49
- let current = obj;
50
- for (let i = 0; i < resolvedPath.length - 1; i++) {
51
- const key = resolvedPath[i];
52
- const nextKey = resolvedPath[i + 1];
53
- if (current[key] == null) {
54
- current[key] = isIndex(nextKey) ? [] : {};
55
- }
56
- current = current[key];
57
- }
58
- const lastKey = resolvedPath[resolvedPath.length - 1];
59
- current[lastKey] = value;
60
- return obj;
61
- }
62
-
63
- // src/compat/array/zipObjectDeep.ts
64
- function zipObjectDeep(keys, values) {
65
- const result = {};
66
- const zipped = zip(keys, values);
67
- for (let i = 0; i < zipped.length; i++) {
68
- const [key, value] = zipped[i];
69
- if (key != null) {
70
- set(result, key, value);
71
- }
72
- }
73
- return result;
74
- }
75
-
76
- export {
77
- set,
78
- zipObjectDeep
79
- };
80
- //# sourceMappingURL=chunk-MKCRW4QT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/compat/_internal/isIndex.ts","../src/compat/_internal/toPath.ts","../src/compat/object/set.ts","../src/compat/array/zipObjectDeep.ts"],"sourcesContent":["const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\\d*)$/\n\nexport function isIndex(value: PropertyKey) {\n switch (typeof value) {\n case 'number': {\n return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;\n }\n case 'symbol': {\n return false;\n }\n case 'string': {\n return IS_UNSIGNED_INTEGER.test(value);\n }\n }\n}","const ESCAPE_REGEXP = /\\\\(\\\\)?/g;\nconst PROPERTY_REGEXP = RegExp(\n // Match anything that isn't a dot or bracket.\n \"[^.[\\\\]]+\" +\n \"|\" +\n // Or match property names within brackets.\n \"\\\\[(?:\" +\n // Match a non-string expression.\n \"([^\\\"'][^[]*)\" +\n \"|\" +\n // Or match strings (supports escaping characters).\n \"([\\\"'])((?:(?!\\\\2)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\2\" +\n \")\\\\]\" +\n \"|\" +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n \"(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))\",\n \"g\",\n);\n\n/**\n * Converts a deep key string into an array of path segments.\n *\n * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.\n *\n * @param deepKey - The deep key string to convert.\n * @returns An array of strings, each representing a segment of the path.\n *\n * Examples:\n *\n * toPath('a.b.c') // Returns ['a', 'b', 'c']\n * toPath('a[b][c]') // Returns ['a', 'b', 'c']\n * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']\n * toPath('a[\"b.c\"].d') // Returns ['a', 'b.c', 'd']\n * toPath('') // Returns []\n * toPath('.a[b].c.d[e][\"f.g\"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']\n */\nexport function toPath(deepKey: string): string[] {\n const result: string[] = [];\n\n if (deepKey[0] === \".\") {\n result.push(\"\");\n }\n\n let match: RegExpExecArray | null;\n\n while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {\n let [key, expr, quote, substr] = match;\n\n if (quote) {\n key = substr.replace(ESCAPE_REGEXP, \"$1\");\n } else if (expr) {\n key = expr.trim();\n }\n\n result.push(key);\n }\n\n return result;\n}\n","import { isIndex } from \"../_internal/isIndex\";\nimport { toPath } from \"../_internal/toPath\";\n\n/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {Settable} obj - The object to modify.\n * @param {Path} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;\nexport function set<T extends object>(obj: T, path: PropertyKey | readonly PropertyKey[], value: unknown): T {\n const resolvedPath = Array.isArray(path)\n ? path\n : typeof path === 'string'\n ? toPath(path)\n : [path];\n\n let current: any = obj;\n\n for (let i = 0; i < resolvedPath.length - 1; i++) {\n const key = resolvedPath[i];\n const nextKey = resolvedPath[i + 1];\n\n if (current[key] == null) {\n current[key] = isIndex(nextKey) ? [] : {};\n }\n\n current = current[key];\n }\n\n const lastKey = resolvedPath[resolvedPath.length - 1];\n current[lastKey] = value;\n\n return obj;\n}\n","import { zip } from \"../../array/zip.ts\";\nimport { set } from \"../object/set.ts\";\n\n/**\n * Creates a deeply nested object given arrays of paths and values.\n *\n * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.\n * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.\n * Paths can be dot-separated strings or arrays of property names.\n * \n * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.\n *\n * @template V - The type of elements in the array.\n * @param {string[] | string[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.\n * @param {V[]} values - An array of values corresponding to the property paths.\n * @returns {object} A new object composed of the given property paths and values.\n *\n * @example\n * const paths = ['a.b.c', 'd.e.f'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n *\n * @example\n * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n * \n * @example\n * const paths = ['a.b[0].c', 'a.b[1].d'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\nexport function zipObjectDeep<P extends string | number | symbol, V>(keys: P[], values: V[]): { [K in P]: V } {\n const result = {} as { [K in P]: V };\n const zipped = zip(keys, values);\n\n for (let i = 0; i < zipped.length; i++) {\n const [key, value] = zipped[i];\n\n if (key != null) {\n set(result, key, value);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;AAAA,IAAM,sBAAsB;AAErB,SAAS,QAAQ,OAAoB;AAC1C,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK,UAAU;AACb,aAAO,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,QAAQ,OAAO;AAAA,IACjE;AAAA,IACA,KAAK,UAAU;AACb,aAAO;AAAA,IACT;AAAA,IACA,KAAK,UAAU;AACb,aAAO,oBAAoB,KAAK,KAAK;AAAA,IACvC;AAAA,EACF;AACF;;;ACdA,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AAAA;AAAA,EAEtB;AAAA,EAaA;AACF;AAmBO,SAAS,OAAO,SAA2B;AAChD,QAAM,SAAmB,CAAC;AAE1B,MAAI,QAAQ,CAAC,MAAM,KAAK;AACtB,WAAO,KAAK,EAAE;AAAA,EAChB;AAEA,MAAI;AAEJ,UAAQ,QAAQ,gBAAgB,KAAK,OAAO,OAAO,MAAM;AACvD,QAAI,CAAC,KAAK,MAAM,OAAO,MAAM,IAAI;AAEjC,QAAI,OAAO;AACT,YAAM,OAAO,QAAQ,eAAe,IAAI;AAAA,IAC1C,WAAW,MAAM;AACf,YAAM,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,KAAK,GAAG;AAAA,EACjB;AAEA,SAAO;AACT;;;AC3BO,SAAS,IAAsB,KAAQ,MAA4C,OAAmB;AAC3G,QAAM,eAAe,MAAM,QAAQ,IAAI,IACnC,OACA,OAAO,SAAS,WACd,OAAO,IAAI,IACX,CAAC,IAAI;AAEX,MAAI,UAAe;AAEnB,WAAS,IAAI,GAAG,IAAI,aAAa,SAAS,GAAG,KAAK;AAChD,UAAM,MAAM,aAAa,CAAC;AAC1B,UAAM,UAAU,aAAa,IAAI,CAAC;AAElC,QAAI,QAAQ,GAAG,KAAK,MAAM;AACxB,cAAQ,GAAG,IAAI,QAAQ,OAAO,IAAI,CAAC,IAAI,CAAC;AAAA,IAC1C;AAEA,cAAU,QAAQ,GAAG;AAAA,EACvB;AAEA,QAAM,UAAU,aAAa,aAAa,SAAS,CAAC;AACpD,UAAQ,OAAO,IAAI;AAEnB,SAAO;AACT;;;ACpBO,SAAS,cAAqD,MAAW,QAA8B;AAC5G,QAAM,SAAS,CAAC;AAChB,QAAM,SAAS,IAAI,MAAM,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,CAAC,KAAK,KAAK,IAAI,OAAO,CAAC;AAE7B,QAAI,OAAO,MAAM;AACf,UAAI,QAAQ,KAAK,KAAK;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,37 +0,0 @@
1
- /**
2
- * Creates a deeply nested object given arrays of paths and values.
3
- *
4
- * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.
5
- * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.
6
- * Paths can be dot-separated strings or arrays of property names.
7
- *
8
- * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.
9
- *
10
- * @template V - The type of elements in the array.
11
- * @param {string[] | string[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.
12
- * @param {V[]} values - An array of values corresponding to the property paths.
13
- * @returns {object} A new object composed of the given property paths and values.
14
- *
15
- * @example
16
- * const paths = ['a.b.c', 'd.e.f'];
17
- * const values = [1, 2];
18
- * const result = zipObjectDeep(paths, values);
19
- * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
20
- *
21
- * @example
22
- * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];
23
- * const values = [1, 2];
24
- * const result = zipObjectDeep(paths, values);
25
- * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
26
- *
27
- * @example
28
- * const paths = ['a.b[0].c', 'a.b[1].d'];
29
- * const values = [1, 2];
30
- * const result = zipObjectDeep(paths, values);
31
- * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
32
- */
33
- declare function zipObjectDeep<P extends string | number | symbol, V>(keys: P[], values: V[]): {
34
- [K in P]: V;
35
- };
36
-
37
- export { zipObjectDeep as z };
@@ -1,37 +0,0 @@
1
- /**
2
- * Creates a deeply nested object given arrays of paths and values.
3
- *
4
- * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.
5
- * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.
6
- * Paths can be dot-separated strings or arrays of property names.
7
- *
8
- * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.
9
- *
10
- * @template V - The type of elements in the array.
11
- * @param {string[] | string[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.
12
- * @param {V[]} values - An array of values corresponding to the property paths.
13
- * @returns {object} A new object composed of the given property paths and values.
14
- *
15
- * @example
16
- * const paths = ['a.b.c', 'd.e.f'];
17
- * const values = [1, 2];
18
- * const result = zipObjectDeep(paths, values);
19
- * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
20
- *
21
- * @example
22
- * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];
23
- * const values = [1, 2];
24
- * const result = zipObjectDeep(paths, values);
25
- * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
26
- *
27
- * @example
28
- * const paths = ['a.b[0].c', 'a.b[1].d'];
29
- * const values = [1, 2];
30
- * const result = zipObjectDeep(paths, values);
31
- * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
32
- */
33
- declare function zipObjectDeep<P extends string | number | symbol, V>(keys: P[], values: V[]): {
34
- [K in P]: V;
35
- };
36
-
37
- export { zipObjectDeep as z };