es-toolkit 1.34.1-dev.1149 → 1.34.1-dev.1152
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/_chunk/{zipWith-ChDTPy.js → zipWith-DXy811.js} +0 -9
- package/dist/array/index.js +10 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/zipObject.d.mts +49 -0
- package/dist/compat/array/zipObject.d.ts +49 -0
- package/dist/compat/array/zipObject.mjs +11 -0
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +10 -2
- package/dist/compat/index.mjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines an array of property names into a single object.
|
|
3
|
+
*
|
|
4
|
+
* This function takes one array containing property names and returns a new object where the property names
|
|
5
|
+
* are keys, and the values are all set to `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* @template P - The type of elements in the array.
|
|
8
|
+
* @param {ArrayLike<K>} keys - An array of property names.
|
|
9
|
+
* @returns {Record<K, undefined>} - A new object composed of the given property names and undefined.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const keys = ['a', 'b', 'c'];
|
|
13
|
+
* const result = zipObject(keys);
|
|
14
|
+
* // result will be { a: undefined, b: undefined, c: undefined }
|
|
15
|
+
*/
|
|
16
|
+
declare function zipObject<K extends PropertyKey>(keys?: ArrayLike<K>): Record<K, undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Combines two arrays, one of property names and one of corresponding values, into a single object.
|
|
19
|
+
*
|
|
20
|
+
* This function takes two arrays: one containing property names and another containing corresponding values.
|
|
21
|
+
* It returns a new object where the property names from the first array are keys, and the corresponding elements
|
|
22
|
+
* from the second array are values. If the `keys` array is longer than the `values` array, the remaining keys will
|
|
23
|
+
* have `undefined` as their values.
|
|
24
|
+
*
|
|
25
|
+
* @template P - The type of elements in the array.
|
|
26
|
+
* @template V - The type of elements in the array.
|
|
27
|
+
* @param {ArrayLike<K>} keys - An array of property names.
|
|
28
|
+
* @param {ArrayLike<V>} values - An array of values corresponding to the property names.
|
|
29
|
+
* @returns {Record<K, V>} - A new object composed of the given property names and values.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const keys = ['a', 'b', 'c'];
|
|
33
|
+
* const values = [1, 2, 3];
|
|
34
|
+
* const result = zipObject(keys, values);
|
|
35
|
+
* // result will be { a: 1, b: 2, c: 3 }
|
|
36
|
+
*
|
|
37
|
+
* const keys2 = ['a', 'b', 'c'];
|
|
38
|
+
* const values2 = [1, 2];
|
|
39
|
+
* const result2 = zipObject(keys2, values2);
|
|
40
|
+
* // result2 will be { a: 1, b: 2, c: undefined }
|
|
41
|
+
*
|
|
42
|
+
* const keys2 = ['a', 'b'];
|
|
43
|
+
* const values2 = [1, 2, 3];
|
|
44
|
+
* const result2 = zipObject(keys2, values2);
|
|
45
|
+
* // result2 will be { a: 1, b: 2 }
|
|
46
|
+
*/
|
|
47
|
+
declare function zipObject<K extends PropertyKey, V>(keys: ArrayLike<K>, values: ArrayLike<V>): Record<K, V>;
|
|
48
|
+
|
|
49
|
+
export { zipObject };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines an array of property names into a single object.
|
|
3
|
+
*
|
|
4
|
+
* This function takes one array containing property names and returns a new object where the property names
|
|
5
|
+
* are keys, and the values are all set to `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* @template P - The type of elements in the array.
|
|
8
|
+
* @param {ArrayLike<K>} keys - An array of property names.
|
|
9
|
+
* @returns {Record<K, undefined>} - A new object composed of the given property names and undefined.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const keys = ['a', 'b', 'c'];
|
|
13
|
+
* const result = zipObject(keys);
|
|
14
|
+
* // result will be { a: undefined, b: undefined, c: undefined }
|
|
15
|
+
*/
|
|
16
|
+
declare function zipObject<K extends PropertyKey>(keys?: ArrayLike<K>): Record<K, undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Combines two arrays, one of property names and one of corresponding values, into a single object.
|
|
19
|
+
*
|
|
20
|
+
* This function takes two arrays: one containing property names and another containing corresponding values.
|
|
21
|
+
* It returns a new object where the property names from the first array are keys, and the corresponding elements
|
|
22
|
+
* from the second array are values. If the `keys` array is longer than the `values` array, the remaining keys will
|
|
23
|
+
* have `undefined` as their values.
|
|
24
|
+
*
|
|
25
|
+
* @template P - The type of elements in the array.
|
|
26
|
+
* @template V - The type of elements in the array.
|
|
27
|
+
* @param {ArrayLike<K>} keys - An array of property names.
|
|
28
|
+
* @param {ArrayLike<V>} values - An array of values corresponding to the property names.
|
|
29
|
+
* @returns {Record<K, V>} - A new object composed of the given property names and values.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const keys = ['a', 'b', 'c'];
|
|
33
|
+
* const values = [1, 2, 3];
|
|
34
|
+
* const result = zipObject(keys, values);
|
|
35
|
+
* // result will be { a: 1, b: 2, c: 3 }
|
|
36
|
+
*
|
|
37
|
+
* const keys2 = ['a', 'b', 'c'];
|
|
38
|
+
* const values2 = [1, 2];
|
|
39
|
+
* const result2 = zipObject(keys2, values2);
|
|
40
|
+
* // result2 will be { a: 1, b: 2, c: undefined }
|
|
41
|
+
*
|
|
42
|
+
* const keys2 = ['a', 'b'];
|
|
43
|
+
* const values2 = [1, 2, 3];
|
|
44
|
+
* const result2 = zipObject(keys2, values2);
|
|
45
|
+
* // result2 will be { a: 1, b: 2 }
|
|
46
|
+
*/
|
|
47
|
+
declare function zipObject<K extends PropertyKey, V>(keys: ArrayLike<K>, values: ArrayLike<V>): Record<K, V>;
|
|
48
|
+
|
|
49
|
+
export { zipObject };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assignValue } from '../_internal/assignValue.mjs';
|
|
2
|
+
|
|
3
|
+
function zipObject(keys = [], values = []) {
|
|
4
|
+
const result = {};
|
|
5
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6
|
+
assignValue(result, keys[i], values[i]);
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { zipObject };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -18,7 +18,6 @@ export { windowed } from '../array/windowed.mjs';
|
|
|
18
18
|
export { xor } from '../array/xor.mjs';
|
|
19
19
|
export { xorBy } from '../array/xorBy.mjs';
|
|
20
20
|
export { xorWith } from '../array/xorWith.mjs';
|
|
21
|
-
export { zipObject } from '../array/zipObject.mjs';
|
|
22
21
|
export { zipWith } from '../array/zipWith.mjs';
|
|
23
22
|
export { AbortError } from '../error/AbortError.mjs';
|
|
24
23
|
export { TimeoutError } from '../error/TimeoutError.mjs';
|
|
@@ -130,6 +129,7 @@ export { uniqWith } from './array/uniqWith.mjs';
|
|
|
130
129
|
export { unzip } from './array/unzip.mjs';
|
|
131
130
|
export { without } from './array/without.mjs';
|
|
132
131
|
export { zip } from './array/zip.mjs';
|
|
132
|
+
export { zipObject } from './array/zipObject.mjs';
|
|
133
133
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
134
134
|
export { after } from './function/after.mjs';
|
|
135
135
|
export { ary } from './function/ary.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export { windowed } from '../array/windowed.js';
|
|
|
18
18
|
export { xor } from '../array/xor.js';
|
|
19
19
|
export { xorBy } from '../array/xorBy.js';
|
|
20
20
|
export { xorWith } from '../array/xorWith.js';
|
|
21
|
-
export { zipObject } from '../array/zipObject.js';
|
|
22
21
|
export { zipWith } from '../array/zipWith.js';
|
|
23
22
|
export { AbortError } from '../error/AbortError.js';
|
|
24
23
|
export { TimeoutError } from '../error/TimeoutError.js';
|
|
@@ -130,6 +129,7 @@ export { uniqWith } from './array/uniqWith.js';
|
|
|
130
129
|
export { unzip } from './array/unzip.js';
|
|
131
130
|
export { without } from './array/without.js';
|
|
132
131
|
export { zip } from './array/zip.js';
|
|
132
|
+
export { zipObject } from './array/zipObject.js';
|
|
133
133
|
export { zipObjectDeep } from './array/zipObjectDeep.js';
|
|
134
134
|
export { after } from './function/after.js';
|
|
135
135
|
export { ary } from './function/ary.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('../_chunk/zipWith-
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-DXy811.js');
|
|
6
6
|
const AbortError = require('../_chunk/AbortError-Cg4ZQ1.js');
|
|
7
7
|
const error_index = require('../error/index.js');
|
|
8
8
|
const unary = require('../_chunk/unary-c1NFA5.js');
|
|
@@ -1666,6 +1666,14 @@ const assignValue = (object, key, value) => {
|
|
|
1666
1666
|
}
|
|
1667
1667
|
};
|
|
1668
1668
|
|
|
1669
|
+
function zipObject(keys = [], values = []) {
|
|
1670
|
+
const result = {};
|
|
1671
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1672
|
+
assignValue(result, keys[i], values[i]);
|
|
1673
|
+
}
|
|
1674
|
+
return result;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1669
1677
|
function updateWith(obj, path, updater, customizer) {
|
|
1670
1678
|
if (obj == null && !isObject(obj)) {
|
|
1671
1679
|
return obj;
|
|
@@ -3680,7 +3688,6 @@ exports.windowed = zipWith.windowed;
|
|
|
3680
3688
|
exports.xor = zipWith.xor;
|
|
3681
3689
|
exports.xorBy = zipWith.xorBy;
|
|
3682
3690
|
exports.xorWith = zipWith.xorWith;
|
|
3683
|
-
exports.zipObject = zipWith.zipObject;
|
|
3684
3691
|
exports.zipWith = zipWith.zipWith;
|
|
3685
3692
|
exports.AbortError = AbortError.AbortError;
|
|
3686
3693
|
exports.TimeoutError = error_index.TimeoutError;
|
|
@@ -3964,4 +3971,5 @@ exports.valuesIn = valuesIn;
|
|
|
3964
3971
|
exports.without = without;
|
|
3965
3972
|
exports.words = words;
|
|
3966
3973
|
exports.zip = zip;
|
|
3974
|
+
exports.zipObject = zipObject;
|
|
3967
3975
|
exports.zipObjectDeep = zipObjectDeep;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -18,7 +18,6 @@ export { windowed } from '../array/windowed.mjs';
|
|
|
18
18
|
export { xor } from '../array/xor.mjs';
|
|
19
19
|
export { xorBy } from '../array/xorBy.mjs';
|
|
20
20
|
export { xorWith } from '../array/xorWith.mjs';
|
|
21
|
-
export { zipObject } from '../array/zipObject.mjs';
|
|
22
21
|
export { zipWith } from '../array/zipWith.mjs';
|
|
23
22
|
export { AbortError } from '../error/AbortError.mjs';
|
|
24
23
|
export { TimeoutError } from '../error/TimeoutError.mjs';
|
|
@@ -132,6 +131,7 @@ export { uniqWith } from './array/uniqWith.mjs';
|
|
|
132
131
|
export { unzip } from './array/unzip.mjs';
|
|
133
132
|
export { without } from './array/without.mjs';
|
|
134
133
|
export { zip } from './array/zip.mjs';
|
|
134
|
+
export { zipObject } from './array/zipObject.mjs';
|
|
135
135
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
136
136
|
export { after } from './function/after.mjs';
|
|
137
137
|
export { ary } from './function/ary.mjs';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('./_chunk/zipWith-
|
|
5
|
+
const zipWith = require('./_chunk/zipWith-DXy811.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
7
|
const AbortError = require('./_chunk/AbortError-Cg4ZQ1.js');
|
|
8
8
|
const error_index = require('./error/index.js');
|
|
@@ -80,12 +80,12 @@ exports.xor = zipWith.xor;
|
|
|
80
80
|
exports.xorBy = zipWith.xorBy;
|
|
81
81
|
exports.xorWith = zipWith.xorWith;
|
|
82
82
|
exports.zip = zipWith.zip;
|
|
83
|
-
exports.zipObject = zipWith.zipObject;
|
|
84
83
|
exports.zipWith = zipWith.zipWith;
|
|
85
84
|
exports.orderBy = array_index.orderBy;
|
|
86
85
|
exports.sortBy = array_index.sortBy;
|
|
87
86
|
exports.takeRightWhile = array_index.takeRightWhile;
|
|
88
87
|
exports.takeWhile = array_index.takeWhile;
|
|
88
|
+
exports.zipObject = array_index.zipObject;
|
|
89
89
|
exports.AbortError = AbortError.AbortError;
|
|
90
90
|
exports.TimeoutError = error_index.TimeoutError;
|
|
91
91
|
exports.after = unary.after;
|
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.34.1-dev.
|
|
4
|
+
"version": "1.34.1-dev.1152+7de44382",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|