es-toolkit 1.10.1-dev.231 → 1.10.1-dev.238

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.
@@ -1,5 +1,4 @@
1
1
  import "../chunk-NKLIE2OI.mjs";
2
- import "../chunk-ARZ5BDR6.mjs";
3
2
  import "../chunk-XT74R35S.mjs";
4
3
  import {
5
4
  camelCase
@@ -36,13 +35,11 @@ import {
36
35
  import {
37
36
  isUndefined
38
37
  } from "../chunk-VH2PV426.mjs";
38
+ import "../chunk-ARZ5BDR6.mjs";
39
39
  import {
40
40
  delay
41
41
  } from "../chunk-O64NE2P4.mjs";
42
- import "../chunk-54TK5BIS.mjs";
43
- import {
44
- set
45
- } from "../chunk-GL7PPRA4.mjs";
42
+ import "../chunk-OSOLEQLZ.mjs";
46
43
  import {
47
44
  clone
48
45
  } from "../chunk-U4JGKZ56.mjs";
@@ -86,7 +83,10 @@ import {
86
83
  import {
87
84
  inRange
88
85
  } from "../chunk-BH6HLGBA.mjs";
89
- import "../chunk-DDH7K4QM.mjs";
86
+ import {
87
+ set,
88
+ zipObjectDeep
89
+ } from "../chunk-MKCRW4QT.mjs";
90
90
  import {
91
91
  xor
92
92
  } from "../chunk-L7FQX5MN.mjs";
@@ -362,6 +362,7 @@ export {
362
362
  xorWith,
363
363
  zip,
364
364
  zipObject,
365
+ zipObjectDeep,
365
366
  zipWith
366
367
  };
367
368
  //# sourceMappingURL=index.mjs.map
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';
@@ -71,7 +72,6 @@ export { pick } from './object/pick.mjs';
71
72
  export { pickBy } from './object/pickBy.mjs';
72
73
  export { invert } from './object/invert.mjs';
73
74
  export { clone } from './object/clone.mjs';
74
- export { set } from './object/set.mjs';
75
75
  export { isEqual } from './predicate/isEqual.mjs';
76
76
  export { isNil } from './predicate/isNil.mjs';
77
77
  export { isNotNil } from './predicate/isNotNil.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';
@@ -71,7 +72,6 @@ export { pick } from './object/pick.js';
71
72
  export { pickBy } from './object/pickBy.js';
72
73
  export { invert } from './object/invert.js';
73
74
  export { clone } from './object/clone.js';
74
- export { set } from './object/set.js';
75
75
  export { isEqual } from './predicate/isEqual.js';
76
76
  export { isNil } from './predicate/isNil.js';
77
77
  export { isNotNil } from './predicate/isNotNil.js';
package/dist/index.js CHANGED
@@ -92,7 +92,6 @@ __export(src_exports, {
92
92
  round: () => round,
93
93
  sample: () => sample,
94
94
  sampleSize: () => sampleSize,
95
- set: () => set,
96
95
  shuffle: () => shuffle,
97
96
  snakeCase: () => snakeCase,
98
97
  startCase: () => startCase,
@@ -119,6 +118,7 @@ __export(src_exports, {
119
118
  xorWith: () => xorWith,
120
119
  zip: () => zip,
121
120
  zipObject: () => zipObject,
121
+ zipObjectDeep: () => zipObjectDeep,
122
122
  zipWith: () => zipWith
123
123
  });
124
124
  module.exports = __toCommonJS(src_exports);
@@ -581,6 +581,77 @@ function zipObject(keys, values) {
581
581
  return result;
582
582
  }
583
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
+
584
655
  // src/array/zipWith.ts
585
656
  function zipWith(arr1, ...rest) {
586
657
  const arrs = [arr1, ...rest.slice(0, -1)];
@@ -882,27 +953,6 @@ function isPrimitive(value) {
882
953
  return value == null || typeof value !== "object" && typeof value !== "function";
883
954
  }
884
955
 
885
- // src/object/set.ts
886
- function set(obj, path, value) {
887
- if (obj instanceof Map || obj instanceof Set) {
888
- throw new TypeError("Set or Map is not supported");
889
- }
890
- const keys = Array.isArray(path) ? path : String(path).replace(/\[|\]/g, (match) => {
891
- return match === "[" ? "." : "";
892
- }).split(".");
893
- let pointer = obj;
894
- for (let i = 0; i < keys.length - 1; i++) {
895
- const key = keys[i];
896
- const nextKey = keys[i + 1];
897
- if (pointer[key] == null || typeof pointer[key] !== "object") {
898
- pointer[key] = /^\d+$/.test(nextKey) ? [] : {};
899
- }
900
- pointer = pointer[key];
901
- }
902
- pointer[keys[keys.length - 1]] = value;
903
- return obj;
904
- }
905
-
906
956
  // src/predicate/isEqual.ts
907
957
  function isEqual(a, b) {
908
958
  if (Object.is(a, b)) {
@@ -1090,7 +1140,6 @@ function startCase(str) {
1090
1140
  round,
1091
1141
  sample,
1092
1142
  sampleSize,
1093
- set,
1094
1143
  shuffle,
1095
1144
  snakeCase,
1096
1145
  startCase,
@@ -1117,6 +1166,7 @@ function startCase(str) {
1117
1166
  xorWith,
1118
1167
  zip,
1119
1168
  zipObject,
1169
+ zipObjectDeep,
1120
1170
  zipWith
1121
1171
  });
1122
1172
  //# sourceMappingURL=index.js.map