es-toolkit 1.17.0-dev.531 → 1.17.0-dev.532
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/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +9 -0
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/object/fromPairs.d.mts +22 -0
- package/dist/compat/object/fromPairs.d.ts +22 -0
- package/dist/compat/object/fromPairs.mjs +9 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -131,6 +131,7 @@ export { mapKeys } from './object/mapKeys.mjs';
|
|
|
131
131
|
export { mapValues } from './object/mapValues.mjs';
|
|
132
132
|
export { merge } from './object/merge.mjs';
|
|
133
133
|
export { mergeWith } from './object/mergeWith.mjs';
|
|
134
|
+
export { fromPairs } from './object/fromPairs.mjs';
|
|
134
135
|
export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
135
136
|
export { isArray } from './predicate/isArray.mjs';
|
|
136
137
|
export { isArguments } from './predicate/isArguments.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export { mapKeys } from './object/mapKeys.js';
|
|
|
131
131
|
export { mapValues } from './object/mapValues.js';
|
|
132
132
|
export { merge } from './object/merge.js';
|
|
133
133
|
export { mergeWith } from './object/mergeWith.js';
|
|
134
|
+
export { fromPairs } from './object/fromPairs.js';
|
|
134
135
|
export { isPlainObject } from './predicate/isPlainObject.js';
|
|
135
136
|
export { isArray } from './predicate/isArray.js';
|
|
136
137
|
export { isArguments } from './predicate/isArguments.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -797,6 +797,14 @@ function merge(object, ...sources) {
|
|
|
797
797
|
return mergeWith(object, ...sources, rest$1.noop);
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
+
function fromPairs(data) {
|
|
801
|
+
const obj = {};
|
|
802
|
+
for (const [key, value] of data) {
|
|
803
|
+
obj[key] = value;
|
|
804
|
+
}
|
|
805
|
+
return obj;
|
|
806
|
+
}
|
|
807
|
+
|
|
800
808
|
function isArray(value) {
|
|
801
809
|
return Array.isArray(value);
|
|
802
810
|
}
|
|
@@ -1002,6 +1010,7 @@ exports.findIndex = findIndex;
|
|
|
1002
1010
|
exports.flatten = flatten;
|
|
1003
1011
|
exports.flattenDeep = flattenDeep;
|
|
1004
1012
|
exports.flattenDepth = flattenDepth;
|
|
1013
|
+
exports.fromPairs = fromPairs;
|
|
1005
1014
|
exports.get = get;
|
|
1006
1015
|
exports.has = has;
|
|
1007
1016
|
exports.indexOf = indexOf;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -132,6 +132,7 @@ export { mapKeys } from './object/mapKeys.mjs';
|
|
|
132
132
|
export { mapValues } from './object/mapValues.mjs';
|
|
133
133
|
export { merge } from './object/merge.mjs';
|
|
134
134
|
export { mergeWith } from './object/mergeWith.mjs';
|
|
135
|
+
export { fromPairs } from './object/fromPairs.mjs';
|
|
135
136
|
export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
136
137
|
export { isArray } from './predicate/isArray.mjs';
|
|
137
138
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms an array of key-value pairs into an object.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} data - An array of key-value pairs.
|
|
5
|
+
* @returns {Record<T, U>} - An object with keys and values from the input array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const pairs = [['a', 1], ['b', 2]];
|
|
9
|
+
*
|
|
10
|
+
* const object = fromPairs(pairs);
|
|
11
|
+
* console.log(object);
|
|
12
|
+
* // Output:
|
|
13
|
+
* // {
|
|
14
|
+
* // a: 1,
|
|
15
|
+
* // b: 2
|
|
16
|
+
* // }
|
|
17
|
+
*/
|
|
18
|
+
declare function fromPairs<T extends PropertyKey, U>(data: Array<[PropertyKey, U]> | Map<PropertyKey, U>): {
|
|
19
|
+
[key in T]: U;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { fromPairs };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms an array of key-value pairs into an object.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} data - An array of key-value pairs.
|
|
5
|
+
* @returns {Record<T, U>} - An object with keys and values from the input array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const pairs = [['a', 1], ['b', 2]];
|
|
9
|
+
*
|
|
10
|
+
* const object = fromPairs(pairs);
|
|
11
|
+
* console.log(object);
|
|
12
|
+
* // Output:
|
|
13
|
+
* // {
|
|
14
|
+
* // a: 1,
|
|
15
|
+
* // b: 2
|
|
16
|
+
* // }
|
|
17
|
+
*/
|
|
18
|
+
declare function fromPairs<T extends PropertyKey, U>(data: Array<[PropertyKey, U]> | Map<PropertyKey, U>): {
|
|
19
|
+
[key in T]: U;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { fromPairs };
|
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.17.0-dev.
|
|
4
|
+
"version": "1.17.0-dev.532+fd2658e2",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|