es-toolkit 1.10.1-dev.228 → 1.10.1-dev.229

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,4 +1,10 @@
1
1
  import "../chunk-DDH7K4QM.mjs";
2
+ import {
3
+ unzipWith
4
+ } from "../chunk-IFNXROZR.mjs";
5
+ import {
6
+ without
7
+ } from "../chunk-PYEYV7BY.mjs";
2
8
  import {
3
9
  xor
4
10
  } from "../chunk-L7FQX5MN.mjs";
@@ -17,12 +23,21 @@ import {
17
23
  import {
18
24
  zipWith
19
25
  } from "../chunk-4KYXHZ4R.mjs";
26
+ import {
27
+ toFilled
28
+ } from "../chunk-OP4OAKQJ.mjs";
29
+ import {
30
+ union
31
+ } from "../chunk-R6QA7PLZ.mjs";
20
32
  import {
21
33
  unionBy
22
34
  } from "../chunk-NFS7RWWE.mjs";
23
35
  import {
24
36
  unionWith
25
37
  } from "../chunk-2ZCITDMK.mjs";
38
+ import {
39
+ uniq
40
+ } from "../chunk-DVK2N4KC.mjs";
26
41
  import {
27
42
  uniqBy
28
43
  } from "../chunk-OXAZEEGP.mjs";
@@ -33,11 +48,13 @@ import {
33
48
  unzip
34
49
  } from "../chunk-UYZKMBDO.mjs";
35
50
  import {
36
- unzipWith
37
- } from "../chunk-IFNXROZR.mjs";
51
+ sample
52
+ } from "../chunk-2KNLZB7V.mjs";
38
53
  import {
39
- without
40
- } from "../chunk-PYEYV7BY.mjs";
54
+ sampleSize
55
+ } from "../chunk-EHSKB6DF.mjs";
56
+ import "../chunk-GIWAOOFY.mjs";
57
+ import "../chunk-SYWMYQYJ.mjs";
41
58
  import {
42
59
  shuffle
43
60
  } from "../chunk-G7UQ5PUR.mjs";
@@ -57,14 +74,11 @@ import {
57
74
  takeWhile
58
75
  } from "../chunk-2IXFGSUA.mjs";
59
76
  import {
60
- toFilled
61
- } from "../chunk-OP4OAKQJ.mjs";
62
- import {
63
- union
64
- } from "../chunk-R6QA7PLZ.mjs";
77
+ intersectionBy
78
+ } from "../chunk-O6UXZR3U.mjs";
65
79
  import {
66
- uniq
67
- } from "../chunk-DVK2N4KC.mjs";
80
+ intersectionWith
81
+ } from "../chunk-XI7KRD2C.mjs";
68
82
  import {
69
83
  keyBy
70
84
  } from "../chunk-AJKZMN2V.mjs";
@@ -84,13 +98,8 @@ import {
84
98
  partition
85
99
  } from "../chunk-DN3NOZ3H.mjs";
86
100
  import {
87
- sample
88
- } from "../chunk-2KNLZB7V.mjs";
89
- import {
90
- sampleSize
91
- } from "../chunk-EHSKB6DF.mjs";
92
- import "../chunk-GIWAOOFY.mjs";
93
- import "../chunk-SYWMYQYJ.mjs";
101
+ flattenDeep
102
+ } from "../chunk-ML727RRJ.mjs";
94
103
  import {
95
104
  forEachRight
96
105
  } from "../chunk-IEA53J7P.mjs";
@@ -107,11 +116,11 @@ import {
107
116
  intersection
108
117
  } from "../chunk-FVVSE2F2.mjs";
109
118
  import {
110
- intersectionBy
111
- } from "../chunk-O6UXZR3U.mjs";
119
+ differenceBy
120
+ } from "../chunk-LVWX5B43.mjs";
112
121
  import {
113
- intersectionWith
114
- } from "../chunk-XI7KRD2C.mjs";
122
+ differenceWith
123
+ } from "../chunk-6NVQAHXP.mjs";
115
124
  import {
116
125
  drop
117
126
  } from "../chunk-S3CORED5.mjs";
@@ -130,9 +139,6 @@ import {
130
139
  import {
131
140
  flatMap
132
141
  } from "../chunk-KBXHURLW.mjs";
133
- import {
134
- flattenDeep
135
- } from "../chunk-ML727RRJ.mjs";
136
142
  import {
137
143
  flatten
138
144
  } from "../chunk-33MSBDC6.mjs";
@@ -148,12 +154,6 @@ import {
148
154
  import {
149
155
  difference
150
156
  } from "../chunk-JPUKH67K.mjs";
151
- import {
152
- differenceBy
153
- } from "../chunk-LVWX5B43.mjs";
154
- import {
155
- differenceWith
156
- } from "../chunk-6NVQAHXP.mjs";
157
157
  import "../chunk-2MM5EJJX.mjs";
158
158
  export {
159
159
  chunk,
@@ -1,7 +1,9 @@
1
1
  // src/object/invert.ts
2
2
  function invert(obj) {
3
3
  const result = {};
4
- for (const key in obj) {
4
+ const keys = Object.keys(obj);
5
+ for (let i = 0; i < keys.length; i++) {
6
+ const key = keys[i];
5
7
  const value = obj[key];
6
8
  result[value] = key;
7
9
  }
@@ -11,4 +13,4 @@ function invert(obj) {
11
13
  export {
12
14
  invert
13
15
  };
14
- //# sourceMappingURL=chunk-74WWMNZS.mjs.map
16
+ //# sourceMappingURL=chunk-OLX53VEF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/object/invert.ts"],"sourcesContent":["/**\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 for (const key in obj) {\n const value = obj[key as K] as V;\n result[value] = key;\n }\n\n return result;\n}\n"],"mappings":";AAkBO,SAAS,OAAqD,KAAsC;AACzG,QAAM,SAAS,CAAC;AAEhB,aAAW,OAAO,KAAK;AACrB,UAAM,QAAQ,IAAI,GAAQ;AAC1B,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/object/invert.ts"],"sourcesContent":["/**\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"],"mappings":";AAkBO,SAAS,OAAqD,KAAsC;AACzG,QAAM,SAAS,CAAC;AAEhB,QAAM,OAAO,OAAO,KAAK,GAAG;AAE5B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,UAAM,QAAQ,IAAI,GAAG;AACrB,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
@@ -834,7 +834,9 @@ function pickBy(obj, shouldPick) {
834
834
  // src/object/invert.ts
835
835
  function invert(obj) {
836
836
  const result = {};
837
- for (const key in obj) {
837
+ const keys = Object.keys(obj);
838
+ for (let i = 0; i < keys.length; i++) {
839
+ const key = keys[i];
838
840
  const value = obj[key];
839
841
  result[value] = key;
840
842
  }