es-toolkit 1.13.1-dev.394 → 1.13.1-dev.396
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/{isFunction-Bab14Q.js → isFunction-Cw_tLG.js} +0 -4
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +17 -3
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/object/mapValues.d.mts +40 -0
- package/dist/compat/object/mapValues.d.ts +40 -0
- package/dist/compat/object/mapValues.mjs +20 -0
- package/dist/compat/predicate/isMatch.mjs +0 -1
- package/dist/index.js +1 -1
- package/dist/object/mapValues.d.mts +1 -1
- package/dist/object/mapValues.d.ts +1 -1
- package/dist/predicate/index.js +1 -1
- package/dist/predicate/isEqual.mjs +0 -4
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -72,7 +72,6 @@ export { pickBy } from '../object/pickBy.mjs';
|
|
|
72
72
|
export { invert } from '../object/invert.mjs';
|
|
73
73
|
export { clone } from '../object/clone.mjs';
|
|
74
74
|
export { flattenObject } from '../object/flattenObject.mjs';
|
|
75
|
-
export { mapValues } from '../object/mapValues.mjs';
|
|
76
75
|
export { cloneDeep } from '../object/cloneDeep.mjs';
|
|
77
76
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
78
77
|
export { isNil } from '../predicate/isNil.mjs';
|
|
@@ -105,6 +104,7 @@ export { get } from './object/get.mjs';
|
|
|
105
104
|
export { set } from './object/set.mjs';
|
|
106
105
|
export { property } from './object/property.mjs';
|
|
107
106
|
export { mapKeys } from './object/mapKeys.mjs';
|
|
107
|
+
export { mapValues } from './object/mapValues.mjs';
|
|
108
108
|
export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
109
109
|
export { isArray } from './predicate/isArray.mjs';
|
|
110
110
|
export { isArguments } from './predicate/isArguments.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -72,7 +72,6 @@ export { pickBy } from '../object/pickBy.js';
|
|
|
72
72
|
export { invert } from '../object/invert.js';
|
|
73
73
|
export { clone } from '../object/clone.js';
|
|
74
74
|
export { flattenObject } from '../object/flattenObject.js';
|
|
75
|
-
export { mapValues } from '../object/mapValues.js';
|
|
76
75
|
export { cloneDeep } from '../object/cloneDeep.js';
|
|
77
76
|
export { isEqual } from '../predicate/isEqual.js';
|
|
78
77
|
export { isNil } from '../predicate/isNil.js';
|
|
@@ -105,6 +104,7 @@ export { get } from './object/get.js';
|
|
|
105
104
|
export { set } from './object/set.js';
|
|
106
105
|
export { property } from './object/property.js';
|
|
107
106
|
export { mapKeys } from './object/mapKeys.js';
|
|
107
|
+
export { mapValues } from './object/mapValues.js';
|
|
108
108
|
export { isPlainObject } from './predicate/isPlainObject.js';
|
|
109
109
|
export { isArray } from './predicate/isArray.js';
|
|
110
110
|
export { isArguments } from './predicate/isArguments.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const function_index = require('../function/index.js');
|
|
|
8
8
|
const math_index = require('../math/index.js');
|
|
9
9
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
10
10
|
const object_index = require('../object/index.js');
|
|
11
|
-
const isFunction = require('../_chunk/isFunction-
|
|
11
|
+
const isFunction = require('../_chunk/isFunction-Cw_tLG.js');
|
|
12
12
|
const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
13
13
|
const string_index = require('../string/index.js');
|
|
14
14
|
|
|
@@ -278,6 +278,21 @@ function mapKeys(object, getNewKey) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
function mapValues(object, getNewValue) {
|
|
282
|
+
getNewValue = getNewValue ?? identity;
|
|
283
|
+
switch (typeof getNewValue) {
|
|
284
|
+
case 'string':
|
|
285
|
+
case 'symbol':
|
|
286
|
+
case 'number':
|
|
287
|
+
case 'object': {
|
|
288
|
+
return object_index.mapValues(object, property(getNewValue));
|
|
289
|
+
}
|
|
290
|
+
case 'function': {
|
|
291
|
+
return object_index.mapValues(object, getNewValue);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
281
296
|
function isPlainObject(object) {
|
|
282
297
|
if (typeof object !== 'object') {
|
|
283
298
|
return false;
|
|
@@ -392,7 +407,6 @@ function isMatch(target, source) {
|
|
|
392
407
|
if (source == null) {
|
|
393
408
|
return true;
|
|
394
409
|
}
|
|
395
|
-
source = source ?? {};
|
|
396
410
|
const keys = Object.keys(source);
|
|
397
411
|
if (target == null) {
|
|
398
412
|
if (keys.length === 0) {
|
|
@@ -552,7 +566,6 @@ exports.clone = object_index.clone;
|
|
|
552
566
|
exports.cloneDeep = object_index.cloneDeep;
|
|
553
567
|
exports.flattenObject = object_index.flattenObject;
|
|
554
568
|
exports.invert = object_index.invert;
|
|
555
|
-
exports.mapValues = object_index.mapValues;
|
|
556
569
|
exports.omit = object_index.omit;
|
|
557
570
|
exports.omitBy = object_index.omitBy;
|
|
558
571
|
exports.pick = object_index.pick;
|
|
@@ -591,6 +604,7 @@ exports.isObjectLike = isObjectLike;
|
|
|
591
604
|
exports.isPlainObject = isPlainObject;
|
|
592
605
|
exports.isTypedArray = isTypedArray;
|
|
593
606
|
exports.mapKeys = mapKeys;
|
|
607
|
+
exports.mapValues = mapValues;
|
|
594
608
|
exports.matches = matches;
|
|
595
609
|
exports.max = max;
|
|
596
610
|
exports.min = min;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -72,7 +72,6 @@ export { pickBy } from '../object/pickBy.mjs';
|
|
|
72
72
|
export { invert } from '../object/invert.mjs';
|
|
73
73
|
export { clone } from '../object/clone.mjs';
|
|
74
74
|
export { flattenObject } from '../object/flattenObject.mjs';
|
|
75
|
-
export { mapValues } from '../object/mapValues.mjs';
|
|
76
75
|
export { cloneDeep } from '../object/cloneDeep.mjs';
|
|
77
76
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
78
77
|
export { isNil } from '../predicate/isNil.mjs';
|
|
@@ -105,6 +104,7 @@ export { get } from './object/get.mjs';
|
|
|
105
104
|
export { set } from './object/set.mjs';
|
|
106
105
|
export { property } from './object/property.mjs';
|
|
107
106
|
export { mapKeys } from './object/mapKeys.mjs';
|
|
107
|
+
export { mapValues } from './object/mapValues.mjs';
|
|
108
108
|
export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
109
109
|
export { isArray } from './predicate/isArray.mjs';
|
|
110
110
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
3
|
+
* by running each own enumerable property of the object through the iteratee function.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the object.
|
|
6
|
+
* @template K - The type of the keys in the object.
|
|
7
|
+
* @template V - The type of the new values generated by the iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @param {T} object - The object to iterate over.
|
|
10
|
+
* @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.
|
|
11
|
+
* @returns {Record<K, V>} - Returns the new mapped object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Example usage:
|
|
15
|
+
* const obj = { a: 1, b: 2 };
|
|
16
|
+
* const result = mapValues(obj, (value) => value * 2);
|
|
17
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
18
|
+
*/
|
|
19
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue?: PropertyKey | readonly PropertyKey[] | null | undefined): Record<K, V>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
22
|
+
* by running each own enumerable property of the object through the iteratee function.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of the object.
|
|
25
|
+
* @template K - The type of the keys in the object.
|
|
26
|
+
* @template V - The type of the new values generated by the iteratee function.
|
|
27
|
+
*
|
|
28
|
+
* @param {T} object - The object to iterate over.
|
|
29
|
+
* @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.
|
|
30
|
+
* @returns {Record<K, V>} - Returns the new mapped object.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Example usage:
|
|
34
|
+
* const obj = { a: 1, b: 2 };
|
|
35
|
+
* const result = mapValues(obj, (value) => value * 2);
|
|
36
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
37
|
+
*/
|
|
38
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
|
39
|
+
|
|
40
|
+
export { mapValues };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
3
|
+
* by running each own enumerable property of the object through the iteratee function.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the object.
|
|
6
|
+
* @template K - The type of the keys in the object.
|
|
7
|
+
* @template V - The type of the new values generated by the iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @param {T} object - The object to iterate over.
|
|
10
|
+
* @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.
|
|
11
|
+
* @returns {Record<K, V>} - Returns the new mapped object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Example usage:
|
|
15
|
+
* const obj = { a: 1, b: 2 };
|
|
16
|
+
* const result = mapValues(obj, (value) => value * 2);
|
|
17
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
18
|
+
*/
|
|
19
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue?: PropertyKey | readonly PropertyKey[] | null | undefined): Record<K, V>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
22
|
+
* by running each own enumerable property of the object through the iteratee function.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of the object.
|
|
25
|
+
* @template K - The type of the keys in the object.
|
|
26
|
+
* @template V - The type of the new values generated by the iteratee function.
|
|
27
|
+
*
|
|
28
|
+
* @param {T} object - The object to iterate over.
|
|
29
|
+
* @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.
|
|
30
|
+
* @returns {Record<K, V>} - Returns the new mapped object.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Example usage:
|
|
34
|
+
* const obj = { a: 1, b: 2 };
|
|
35
|
+
* const result = mapValues(obj, (value) => value * 2);
|
|
36
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
37
|
+
*/
|
|
38
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
|
39
|
+
|
|
40
|
+
export { mapValues };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { mapValues as mapValues$1 } from '../../object/mapValues.mjs';
|
|
2
|
+
import { identity } from '../_internal/identity.mjs';
|
|
3
|
+
import { property } from './property.mjs';
|
|
4
|
+
|
|
5
|
+
function mapValues(object, getNewValue) {
|
|
6
|
+
getNewValue = getNewValue ?? identity;
|
|
7
|
+
switch (typeof getNewValue) {
|
|
8
|
+
case 'string':
|
|
9
|
+
case 'symbol':
|
|
10
|
+
case 'number':
|
|
11
|
+
case 'object': {
|
|
12
|
+
return mapValues$1(object, property(getNewValue));
|
|
13
|
+
}
|
|
14
|
+
case 'function': {
|
|
15
|
+
return mapValues$1(object, getNewValue);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { mapValues };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const function_index = require('./function/index.js');
|
|
|
9
9
|
const math_index = require('./math/index.js');
|
|
10
10
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
11
11
|
const object_index = require('./object/index.js');
|
|
12
|
-
const isFunction = require('./_chunk/isFunction-
|
|
12
|
+
const isFunction = require('./_chunk/isFunction-Cw_tLG.js');
|
|
13
13
|
const isTypedArray = require('./_chunk/isTypedArray-BBEkFl.js');
|
|
14
14
|
const predicate_index = require('./predicate/index.js');
|
|
15
15
|
const string_index = require('./string/index.js');
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* const result = mapValues(obj, (value) => value * 2);
|
|
17
17
|
* console.log(result); // { a: 2, b: 4 }
|
|
18
18
|
*/
|
|
19
|
-
declare function mapValues<T extends
|
|
19
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
|
20
20
|
|
|
21
21
|
export { mapValues };
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* const result = mapValues(obj, (value) => value * 2);
|
|
17
17
|
* console.log(result); // { a: 2, b: 4 }
|
|
18
18
|
*/
|
|
19
|
-
declare function mapValues<T extends
|
|
19
|
+
declare function mapValues<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record<K, V>;
|
|
20
20
|
|
|
21
21
|
export { mapValues };
|
package/dist/predicate/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const isFunction = require('../_chunk/isFunction-
|
|
5
|
+
const isFunction = require('../_chunk/isFunction-Cw_tLG.js');
|
|
6
6
|
const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
7
7
|
|
|
8
8
|
function isBoolean(x) {
|
|
@@ -42,7 +42,6 @@ function areObjectsEqual(a, b, stack) {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
switch (aTag) {
|
|
45
|
-
case regexpTag:
|
|
46
45
|
case stringTag:
|
|
47
46
|
return a.toString() === b.toString();
|
|
48
47
|
case numberTag: {
|
|
@@ -141,9 +140,6 @@ function areObjectsEqual(a, b, stack) {
|
|
|
141
140
|
return a.name === b.name && a.message === b.message;
|
|
142
141
|
}
|
|
143
142
|
case objectTag: {
|
|
144
|
-
if (a == null || b == null) {
|
|
145
|
-
return a === b;
|
|
146
|
-
}
|
|
147
143
|
const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack) ||
|
|
148
144
|
(isPlainObject(a) && isPlainObject(b));
|
|
149
145
|
if (!areEqualInstances) {
|
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.13.1-dev.
|
|
4
|
+
"version": "1.13.1-dev.396+4ac49081",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|