es-toolkit 1.14.0-dev.410 → 1.14.0-dev.412
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/{initial-BTrQy1.js → initial-CBsbzo.js} +0 -25
- package/dist/_chunk/{isSymbol-CxBVKi.js → isFunction-D0hq6d.js} +0 -5
- package/dist/array/_internal/compareValues.mjs +22 -0
- package/dist/array/index.js +38 -2
- package/dist/array/orderBy.mjs +2 -9
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/getPath.mjs +26 -0
- package/dist/compat/_internal/isKey.mjs +16 -0
- package/dist/compat/array/orderBy.d.mts +34 -0
- package/dist/compat/array/orderBy.d.ts +34 -0
- package/dist/compat/array/orderBy.mjs +50 -0
- package/dist/compat/index.d.mts +2 -2
- package/dist/compat/index.d.ts +2 -2
- package/dist/compat/index.js +124 -38
- package/dist/compat/index.mjs +2 -2
- package/dist/compat/predicate/isSymbol.d.mts +17 -0
- package/dist/compat/predicate/isSymbol.d.ts +17 -0
- package/dist/compat/predicate/isSymbol.mjs +5 -0
- package/dist/index.js +11 -11
- package/dist/predicate/index.js +13 -9
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isKey } from './isKey.mjs';
|
|
2
|
+
import { toPath } from './toPath.mjs';
|
|
3
|
+
|
|
4
|
+
function getPath(key, object) {
|
|
5
|
+
if (Array.isArray(key)) {
|
|
6
|
+
const path = [];
|
|
7
|
+
for (let i = 0; i < key.length; i++) {
|
|
8
|
+
const k = key[i];
|
|
9
|
+
if (isKey(k, object)) {
|
|
10
|
+
object = object[k];
|
|
11
|
+
path.push(k);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const keys = toPath(k);
|
|
15
|
+
for (let i = 0; i < keys.length; i++) {
|
|
16
|
+
object = object[keys[i]];
|
|
17
|
+
path.push(keys[i]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return path;
|
|
22
|
+
}
|
|
23
|
+
return isKey(key, object) ? key : toPath(key);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { getPath };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isSymbol } from '../predicate/isSymbol.mjs';
|
|
2
|
+
|
|
3
|
+
const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
4
|
+
const regexIsPlainProp = /^\w*$/;
|
|
5
|
+
function isKey(value, object) {
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol(value)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return ((typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||
|
|
13
|
+
(object != null && Object.hasOwn(object, value)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { isKey };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array of objects, an array of keys to sort by, and an array of order directions.
|
|
5
|
+
* It returns the sorted array, ordering by each key according to its corresponding direction
|
|
6
|
+
* ('asc' for ascending or 'desc' for descending). If values for a key are equal,string
|
|
7
|
+
* it moves to the next key to determine the order.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @param {T[] | null} collection - The array of objects to be sorted.
|
|
11
|
+
* @param {string | Array<string | string[]>} keys - An array of keys (property names or property paths) to sort by.
|
|
12
|
+
* @param {unknown | unknown[]} orders - An array of order directions ('asc' for ascending or 'desc' for descending).
|
|
13
|
+
* @returns {T[]} - The sorted array.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Sort an array of objects by 'user' in ascending order and 'age' in descending order.
|
|
17
|
+
* const users = [
|
|
18
|
+
* { user: 'fred', age: 48 },
|
|
19
|
+
* { user: 'barney', age: 34 },
|
|
20
|
+
* { user: 'fred', age: 40 },
|
|
21
|
+
* { user: 'barney', age: 36 },
|
|
22
|
+
* ];
|
|
23
|
+
* const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);
|
|
24
|
+
* // result will be:
|
|
25
|
+
* // [
|
|
26
|
+
* // { user: 'barney', age: 36 },
|
|
27
|
+
* // { user: 'barney', age: 34 },
|
|
28
|
+
* // { user: 'fred', age: 48 },
|
|
29
|
+
* // { user: 'fred', age: 40 },
|
|
30
|
+
* // ]
|
|
31
|
+
*/
|
|
32
|
+
declare function orderBy<T extends object>(collection?: T[] | null, keys?: string | Array<string | string[]>, orders?: unknown | unknown[]): T[];
|
|
33
|
+
|
|
34
|
+
export { orderBy };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorts an array of objects based on multiple properties and their corresponding order directions.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array of objects, an array of keys to sort by, and an array of order directions.
|
|
5
|
+
* It returns the sorted array, ordering by each key according to its corresponding direction
|
|
6
|
+
* ('asc' for ascending or 'desc' for descending). If values for a key are equal,string
|
|
7
|
+
* it moves to the next key to determine the order.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @param {T[] | null} collection - The array of objects to be sorted.
|
|
11
|
+
* @param {string | Array<string | string[]>} keys - An array of keys (property names or property paths) to sort by.
|
|
12
|
+
* @param {unknown | unknown[]} orders - An array of order directions ('asc' for ascending or 'desc' for descending).
|
|
13
|
+
* @returns {T[]} - The sorted array.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Sort an array of objects by 'user' in ascending order and 'age' in descending order.
|
|
17
|
+
* const users = [
|
|
18
|
+
* { user: 'fred', age: 48 },
|
|
19
|
+
* { user: 'barney', age: 34 },
|
|
20
|
+
* { user: 'fred', age: 40 },
|
|
21
|
+
* { user: 'barney', age: 36 },
|
|
22
|
+
* ];
|
|
23
|
+
* const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);
|
|
24
|
+
* // result will be:
|
|
25
|
+
* // [
|
|
26
|
+
* // { user: 'barney', age: 36 },
|
|
27
|
+
* // { user: 'barney', age: 34 },
|
|
28
|
+
* // { user: 'fred', age: 48 },
|
|
29
|
+
* // { user: 'fred', age: 40 },
|
|
30
|
+
* // ]
|
|
31
|
+
*/
|
|
32
|
+
declare function orderBy<T extends object>(collection?: T[] | null, keys?: string | Array<string | string[]>, orders?: unknown | unknown[]): T[];
|
|
33
|
+
|
|
34
|
+
export { orderBy };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getPath } from '../_internal/getPath.mjs';
|
|
2
|
+
|
|
3
|
+
function orderBy(collection, keys, orders) {
|
|
4
|
+
if (collection == null) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
if (!Array.isArray(keys)) {
|
|
8
|
+
keys = keys == null ? [] : [keys];
|
|
9
|
+
}
|
|
10
|
+
if (!Array.isArray(orders)) {
|
|
11
|
+
orders = orders == null ? [] : [orders];
|
|
12
|
+
}
|
|
13
|
+
const compareValues = (a, b, order) => {
|
|
14
|
+
if (a < b) {
|
|
15
|
+
return order === 'desc' ? 1 : -1;
|
|
16
|
+
}
|
|
17
|
+
if (a > b) {
|
|
18
|
+
return order === 'desc' ? -1 : 1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
22
|
+
const getValueByPath = (key, obj) => {
|
|
23
|
+
if (Array.isArray(key)) {
|
|
24
|
+
let value = obj;
|
|
25
|
+
for (let i = 0; i < key.length; i++) {
|
|
26
|
+
value = value[key[i]];
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return obj[key];
|
|
31
|
+
};
|
|
32
|
+
keys = keys.map(key => getPath(key, collection[0]));
|
|
33
|
+
const shallowCopiedCollection = collection.slice();
|
|
34
|
+
const orderedCollection = shallowCopiedCollection.sort((a, b) => {
|
|
35
|
+
for (let i = 0; i < keys.length; i++) {
|
|
36
|
+
const key = keys[i];
|
|
37
|
+
const valueA = getValueByPath(key, a);
|
|
38
|
+
const valueB = getValueByPath(key, b);
|
|
39
|
+
const order = String(orders[i]);
|
|
40
|
+
const comparedResult = compareValues(valueA, valueB, order);
|
|
41
|
+
if (comparedResult !== 0) {
|
|
42
|
+
return comparedResult;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
});
|
|
47
|
+
return orderedCollection;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { orderBy };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@ export { intersectionWith } from '../array/intersectionWith.mjs';
|
|
|
15
15
|
export { keyBy } from '../array/keyBy.mjs';
|
|
16
16
|
export { maxBy } from '../array/maxBy.mjs';
|
|
17
17
|
export { minBy } from '../array/minBy.mjs';
|
|
18
|
-
export { orderBy } from '../array/orderBy.mjs';
|
|
19
18
|
export { partition } from '../array/partition.mjs';
|
|
20
19
|
export { sample } from '../array/sample.mjs';
|
|
21
20
|
export { sampleSize } from '../array/sampleSize.mjs';
|
|
@@ -81,7 +80,6 @@ export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
|
81
80
|
export { isLength } from '../predicate/isLength.mjs';
|
|
82
81
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
83
82
|
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
84
|
-
export { isSymbol } from '../predicate/isSymbol.mjs';
|
|
85
83
|
export { delay } from '../promise/delay.mjs';
|
|
86
84
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
87
85
|
export { camelCase } from '../string/camelCase.mjs';
|
|
@@ -98,6 +96,7 @@ export { fill } from './array/fill.mjs';
|
|
|
98
96
|
export { flatten } from './array/flatten.mjs';
|
|
99
97
|
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
100
98
|
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
99
|
+
export { orderBy } from './array/orderBy.mjs';
|
|
101
100
|
export { size } from './array/size.mjs';
|
|
102
101
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
103
102
|
export { ary } from './function/ary.mjs';
|
|
@@ -113,6 +112,7 @@ export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
|
113
112
|
export { isArray } from './predicate/isArray.mjs';
|
|
114
113
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
115
114
|
export { isArrayLike } from './predicate/isArrayLike.mjs';
|
|
115
|
+
export { isSymbol } from './predicate/isSymbol.mjs';
|
|
116
116
|
export { isObjectLike } from './predicate/isObjectLike.mjs';
|
|
117
117
|
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
118
118
|
export { isTypedArray } from './predicate/isTypedArray.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { intersectionWith } from '../array/intersectionWith.js';
|
|
|
15
15
|
export { keyBy } from '../array/keyBy.js';
|
|
16
16
|
export { maxBy } from '../array/maxBy.js';
|
|
17
17
|
export { minBy } from '../array/minBy.js';
|
|
18
|
-
export { orderBy } from '../array/orderBy.js';
|
|
19
18
|
export { partition } from '../array/partition.js';
|
|
20
19
|
export { sample } from '../array/sample.js';
|
|
21
20
|
export { sampleSize } from '../array/sampleSize.js';
|
|
@@ -81,7 +80,6 @@ export { isUndefined } from '../predicate/isUndefined.js';
|
|
|
81
80
|
export { isLength } from '../predicate/isLength.js';
|
|
82
81
|
export { isFunction } from '../predicate/isFunction.js';
|
|
83
82
|
export { isPrimitive } from '../predicate/isPrimitive.js';
|
|
84
|
-
export { isSymbol } from '../predicate/isSymbol.js';
|
|
85
83
|
export { delay } from '../promise/delay.js';
|
|
86
84
|
export { withTimeout } from '../promise/withTimeout.js';
|
|
87
85
|
export { camelCase } from '../string/camelCase.js';
|
|
@@ -98,6 +96,7 @@ export { fill } from './array/fill.js';
|
|
|
98
96
|
export { flatten } from './array/flatten.js';
|
|
99
97
|
export { flattenDeep } from './array/flattenDeep.js';
|
|
100
98
|
export { flattenDepth } from './array/flattenDepth.js';
|
|
99
|
+
export { orderBy } from './array/orderBy.js';
|
|
101
100
|
export { size } from './array/size.js';
|
|
102
101
|
export { zipObjectDeep } from './array/zipObjectDeep.js';
|
|
103
102
|
export { ary } from './function/ary.js';
|
|
@@ -113,6 +112,7 @@ export { isPlainObject } from './predicate/isPlainObject.js';
|
|
|
113
112
|
export { isArray } from './predicate/isArray.js';
|
|
114
113
|
export { isArguments } from './predicate/isArguments.js';
|
|
115
114
|
export { isArrayLike } from './predicate/isArrayLike.js';
|
|
115
|
+
export { isSymbol } from './predicate/isSymbol.js';
|
|
116
116
|
export { isObjectLike } from './predicate/isObjectLike.js';
|
|
117
117
|
export { isBoolean } from './predicate/isBoolean.js';
|
|
118
118
|
export { isTypedArray } from './predicate/isTypedArray.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const initial = require('../_chunk/initial-
|
|
5
|
+
const initial = require('../_chunk/initial-CBsbzo.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-CwRt_M.js');
|
|
7
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 isObjectLike = require('../_chunk/isObjectLike-BeLCsr.js');
|
|
11
|
-
const
|
|
11
|
+
const isFunction = require('../_chunk/isFunction-D0hq6d.js');
|
|
12
12
|
const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
13
13
|
const string_index = require('../string/index.js');
|
|
14
14
|
|
|
@@ -78,29 +78,21 @@ function flattenDepth(value, depth = 1) {
|
|
|
78
78
|
return flatten(value, depth);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
if (target instanceof Map || target instanceof Set) {
|
|
86
|
-
return target.size;
|
|
87
|
-
}
|
|
88
|
-
return Object.keys(target).length;
|
|
81
|
+
function isSymbol(value) {
|
|
82
|
+
return typeof value === 'symbol' || (value != null && value instanceof Symbol);
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
case 'symbol': {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
case 'string': {
|
|
101
|
-
return IS_UNSIGNED_INTEGER.test(value);
|
|
102
|
-
}
|
|
85
|
+
const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
86
|
+
const regexIsPlainProp = /^\w*$/;
|
|
87
|
+
function isKey(value, object) {
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
return false;
|
|
103
90
|
}
|
|
91
|
+
if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol(value)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return ((typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||
|
|
95
|
+
(object != null && Object.hasOwn(object, value)));
|
|
104
96
|
}
|
|
105
97
|
|
|
106
98
|
function toPath(deepKey) {
|
|
@@ -142,6 +134,100 @@ function toPath(deepKey) {
|
|
|
142
134
|
return result;
|
|
143
135
|
}
|
|
144
136
|
|
|
137
|
+
function getPath(key, object) {
|
|
138
|
+
if (Array.isArray(key)) {
|
|
139
|
+
const path = [];
|
|
140
|
+
for (let i = 0; i < key.length; i++) {
|
|
141
|
+
const k = key[i];
|
|
142
|
+
if (isKey(k, object)) {
|
|
143
|
+
object = object[k];
|
|
144
|
+
path.push(k);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const keys = toPath(k);
|
|
148
|
+
for (let i = 0; i < keys.length; i++) {
|
|
149
|
+
object = object[keys[i]];
|
|
150
|
+
path.push(keys[i]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return path;
|
|
155
|
+
}
|
|
156
|
+
return isKey(key, object) ? key : toPath(key);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function orderBy(collection, keys, orders) {
|
|
160
|
+
if (collection == null) {
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
if (!Array.isArray(keys)) {
|
|
164
|
+
keys = keys == null ? [] : [keys];
|
|
165
|
+
}
|
|
166
|
+
if (!Array.isArray(orders)) {
|
|
167
|
+
orders = orders == null ? [] : [orders];
|
|
168
|
+
}
|
|
169
|
+
const compareValues = (a, b, order) => {
|
|
170
|
+
if (a < b) {
|
|
171
|
+
return order === 'desc' ? 1 : -1;
|
|
172
|
+
}
|
|
173
|
+
if (a > b) {
|
|
174
|
+
return order === 'desc' ? -1 : 1;
|
|
175
|
+
}
|
|
176
|
+
return 0;
|
|
177
|
+
};
|
|
178
|
+
const getValueByPath = (key, obj) => {
|
|
179
|
+
if (Array.isArray(key)) {
|
|
180
|
+
let value = obj;
|
|
181
|
+
for (let i = 0; i < key.length; i++) {
|
|
182
|
+
value = value[key[i]];
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
return obj[key];
|
|
187
|
+
};
|
|
188
|
+
keys = keys.map(key => getPath(key, collection[0]));
|
|
189
|
+
const shallowCopiedCollection = collection.slice();
|
|
190
|
+
const orderedCollection = shallowCopiedCollection.sort((a, b) => {
|
|
191
|
+
for (let i = 0; i < keys.length; i++) {
|
|
192
|
+
const key = keys[i];
|
|
193
|
+
const valueA = getValueByPath(key, a);
|
|
194
|
+
const valueB = getValueByPath(key, b);
|
|
195
|
+
const order = String(orders[i]);
|
|
196
|
+
const comparedResult = compareValues(valueA, valueB, order);
|
|
197
|
+
if (comparedResult !== 0) {
|
|
198
|
+
return comparedResult;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return 0;
|
|
202
|
+
});
|
|
203
|
+
return orderedCollection;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function size(target) {
|
|
207
|
+
if (isFunction.isNil(target)) {
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
if (target instanceof Map || target instanceof Set) {
|
|
211
|
+
return target.size;
|
|
212
|
+
}
|
|
213
|
+
return Object.keys(target).length;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
217
|
+
function isIndex(value) {
|
|
218
|
+
switch (typeof value) {
|
|
219
|
+
case 'number': {
|
|
220
|
+
return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
221
|
+
}
|
|
222
|
+
case 'symbol': {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
case 'string': {
|
|
226
|
+
return IS_UNSIGNED_INTEGER.test(value);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
145
231
|
function set(obj, path, value) {
|
|
146
232
|
const resolvedPath = Array.isArray(path)
|
|
147
233
|
? path
|
|
@@ -294,7 +380,7 @@ function mapValues(object, getNewValue) {
|
|
|
294
380
|
}
|
|
295
381
|
|
|
296
382
|
function isArguments(value) {
|
|
297
|
-
return value !== null && typeof value === 'object' &&
|
|
383
|
+
return value !== null && typeof value === 'object' && isFunction.getTag(value) === '[object Arguments]';
|
|
298
384
|
}
|
|
299
385
|
|
|
300
386
|
function isPlainObject(object) {
|
|
@@ -334,14 +420,14 @@ function cloneDeep(obj) {
|
|
|
334
420
|
return isObjectLike.cloneDeep(obj);
|
|
335
421
|
}
|
|
336
422
|
switch (Object.prototype.toString.call(obj)) {
|
|
337
|
-
case
|
|
338
|
-
case
|
|
339
|
-
case
|
|
423
|
+
case isFunction.numberTag:
|
|
424
|
+
case isFunction.stringTag:
|
|
425
|
+
case isFunction.booleanTag: {
|
|
340
426
|
const result = new obj.constructor(obj?.valueOf());
|
|
341
427
|
isObjectLike.copyProperties(result, obj);
|
|
342
428
|
return result;
|
|
343
429
|
}
|
|
344
|
-
case
|
|
430
|
+
case isFunction.argumentsTag: {
|
|
345
431
|
const result = {};
|
|
346
432
|
isObjectLike.copyProperties(result, obj);
|
|
347
433
|
result.length = obj.length;
|
|
@@ -431,14 +517,14 @@ function isArray(value) {
|
|
|
431
517
|
|
|
432
518
|
function isArrayLike(value) {
|
|
433
519
|
return value != null && typeof value !== "function" &&
|
|
434
|
-
|
|
520
|
+
isFunction.isLength(value.length);
|
|
435
521
|
}
|
|
436
522
|
|
|
437
523
|
function isBoolean(x) {
|
|
438
524
|
if (x === true || x === false) {
|
|
439
525
|
return true;
|
|
440
526
|
}
|
|
441
|
-
if (typeof x === 'object' && x != null &&
|
|
527
|
+
if (typeof x === 'object' && x != null && isFunction.getTag(x) === '[object Boolean]') {
|
|
442
528
|
return true;
|
|
443
529
|
}
|
|
444
530
|
return false;
|
|
@@ -606,7 +692,6 @@ exports.keyBy = initial.keyBy;
|
|
|
606
692
|
exports.last = initial.last;
|
|
607
693
|
exports.maxBy = initial.maxBy;
|
|
608
694
|
exports.minBy = initial.minBy;
|
|
609
|
-
exports.orderBy = initial.orderBy;
|
|
610
695
|
exports.partition = initial.partition;
|
|
611
696
|
exports.sample = initial.sample;
|
|
612
697
|
exports.sampleSize = initial.sampleSize;
|
|
@@ -663,14 +748,13 @@ exports.omit = isObjectLike.omit;
|
|
|
663
748
|
exports.omitBy = isObjectLike.omitBy;
|
|
664
749
|
exports.pick = isObjectLike.pick;
|
|
665
750
|
exports.pickBy = isObjectLike.pickBy;
|
|
666
|
-
exports.isEqual =
|
|
667
|
-
exports.isFunction =
|
|
668
|
-
exports.isLength =
|
|
669
|
-
exports.isNil =
|
|
670
|
-
exports.isNotNil =
|
|
671
|
-
exports.isNull =
|
|
672
|
-
exports.
|
|
673
|
-
exports.isUndefined = isSymbol.isUndefined;
|
|
751
|
+
exports.isEqual = isFunction.isEqual;
|
|
752
|
+
exports.isFunction = isFunction.isFunction;
|
|
753
|
+
exports.isLength = isFunction.isLength;
|
|
754
|
+
exports.isNil = isFunction.isNil;
|
|
755
|
+
exports.isNotNil = isFunction.isNotNil;
|
|
756
|
+
exports.isNull = isFunction.isNull;
|
|
757
|
+
exports.isUndefined = isFunction.isUndefined;
|
|
674
758
|
exports.isPrimitive = isTypedArray$1.isPrimitive;
|
|
675
759
|
exports.camelCase = string_index.camelCase;
|
|
676
760
|
exports.capitalize = string_index.capitalize;
|
|
@@ -696,6 +780,7 @@ exports.isArrayLike = isArrayLike;
|
|
|
696
780
|
exports.isBoolean = isBoolean;
|
|
697
781
|
exports.isMatch = isMatch;
|
|
698
782
|
exports.isPlainObject = isPlainObject;
|
|
783
|
+
exports.isSymbol = isSymbol;
|
|
699
784
|
exports.isTypedArray = isTypedArray;
|
|
700
785
|
exports.mapKeys = mapKeys;
|
|
701
786
|
exports.mapValues = mapValues;
|
|
@@ -704,6 +789,7 @@ exports.max = max;
|
|
|
704
789
|
exports.merge = merge;
|
|
705
790
|
exports.mergeWith = mergeWith;
|
|
706
791
|
exports.min = min;
|
|
792
|
+
exports.orderBy = orderBy;
|
|
707
793
|
exports.padStart = padStart;
|
|
708
794
|
exports.property = property;
|
|
709
795
|
exports.set = set;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -15,7 +15,6 @@ export { intersectionWith } from '../array/intersectionWith.mjs';
|
|
|
15
15
|
export { keyBy } from '../array/keyBy.mjs';
|
|
16
16
|
export { maxBy } from '../array/maxBy.mjs';
|
|
17
17
|
export { minBy } from '../array/minBy.mjs';
|
|
18
|
-
export { orderBy } from '../array/orderBy.mjs';
|
|
19
18
|
export { partition } from '../array/partition.mjs';
|
|
20
19
|
export { sample } from '../array/sample.mjs';
|
|
21
20
|
export { sampleSize } from '../array/sampleSize.mjs';
|
|
@@ -82,7 +81,6 @@ export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
|
82
81
|
export { isLength } from '../predicate/isLength.mjs';
|
|
83
82
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
84
83
|
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
85
|
-
export { isSymbol } from '../predicate/isSymbol.mjs';
|
|
86
84
|
export { delay } from '../promise/delay.mjs';
|
|
87
85
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
88
86
|
export { camelCase } from '../string/camelCase.mjs';
|
|
@@ -99,6 +97,7 @@ export { fill } from './array/fill.mjs';
|
|
|
99
97
|
export { flatten } from './array/flatten.mjs';
|
|
100
98
|
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
101
99
|
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
100
|
+
export { orderBy } from './array/orderBy.mjs';
|
|
102
101
|
export { size } from './array/size.mjs';
|
|
103
102
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
104
103
|
export { ary } from './function/ary.mjs';
|
|
@@ -114,6 +113,7 @@ export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
|
114
113
|
export { isArray } from './predicate/isArray.mjs';
|
|
115
114
|
export { isArguments } from './predicate/isArguments.mjs';
|
|
116
115
|
export { isArrayLike } from './predicate/isArrayLike.mjs';
|
|
116
|
+
export { isSymbol } from './predicate/isSymbol.mjs';
|
|
117
117
|
export { isBoolean } from './predicate/isBoolean.mjs';
|
|
118
118
|
export { isTypedArray } from './predicate/isTypedArray.mjs';
|
|
119
119
|
export { isMatch } from './predicate/isMatch.mjs';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a value is a symbol.
|
|
3
|
+
*
|
|
4
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} value The value to check.
|
|
7
|
+
* @returns {value is symbol} Returns `true` if `value` is a symbol, else `false`.
|
|
8
|
+
* @example
|
|
9
|
+
* isSymbol(Symbol.iterator);
|
|
10
|
+
* // => true
|
|
11
|
+
*
|
|
12
|
+
* isSymbol('abc');
|
|
13
|
+
* // => false
|
|
14
|
+
*/
|
|
15
|
+
declare function isSymbol(value?: unknown): value is symbol;
|
|
16
|
+
|
|
17
|
+
export { isSymbol };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a value is a symbol.
|
|
3
|
+
*
|
|
4
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} value The value to check.
|
|
7
|
+
* @returns {value is symbol} Returns `true` if `value` is a symbol, else `false`.
|
|
8
|
+
* @example
|
|
9
|
+
* isSymbol(Symbol.iterator);
|
|
10
|
+
* // => true
|
|
11
|
+
*
|
|
12
|
+
* isSymbol('abc');
|
|
13
|
+
* // => false
|
|
14
|
+
*/
|
|
15
|
+
declare function isSymbol(value?: unknown): value is symbol;
|
|
16
|
+
|
|
17
|
+
export { isSymbol };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const initial = require('./_chunk/initial-
|
|
5
|
+
const initial = require('./_chunk/initial-CBsbzo.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
7
|
const promise_index = require('./_chunk/index-CwRt_M.js');
|
|
8
8
|
const function_index = require('./function/index.js');
|
|
@@ -10,7 +10,7 @@ const math_index = require('./math/index.js');
|
|
|
10
10
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
11
11
|
const isObjectLike = require('./_chunk/isObjectLike-BeLCsr.js');
|
|
12
12
|
const object_index = require('./object/index.js');
|
|
13
|
-
const
|
|
13
|
+
const isFunction = require('./_chunk/isFunction-D0hq6d.js');
|
|
14
14
|
const isTypedArray = require('./_chunk/isTypedArray-BBEkFl.js');
|
|
15
15
|
const predicate_index = require('./predicate/index.js');
|
|
16
16
|
const string_index = require('./string/index.js');
|
|
@@ -42,7 +42,6 @@ exports.keyBy = initial.keyBy;
|
|
|
42
42
|
exports.last = initial.last;
|
|
43
43
|
exports.maxBy = initial.maxBy;
|
|
44
44
|
exports.minBy = initial.minBy;
|
|
45
|
-
exports.orderBy = initial.orderBy;
|
|
46
45
|
exports.partition = initial.partition;
|
|
47
46
|
exports.sample = initial.sample;
|
|
48
47
|
exports.sampleSize = initial.sampleSize;
|
|
@@ -69,6 +68,7 @@ exports.zip = initial.zip;
|
|
|
69
68
|
exports.zipObject = initial.zipObject;
|
|
70
69
|
exports.zipWith = initial.zipWith;
|
|
71
70
|
exports.flattenDeep = array_index.flattenDeep;
|
|
71
|
+
exports.orderBy = array_index.orderBy;
|
|
72
72
|
exports.AbortError = promise_index.AbortError;
|
|
73
73
|
exports.TimeoutError = promise_index.TimeoutError;
|
|
74
74
|
exports.delay = promise_index.delay;
|
|
@@ -104,18 +104,18 @@ exports.pick = isObjectLike.pick;
|
|
|
104
104
|
exports.pickBy = isObjectLike.pickBy;
|
|
105
105
|
exports.merge = object_index.merge;
|
|
106
106
|
exports.mergeWith = object_index.mergeWith;
|
|
107
|
-
exports.isEqual =
|
|
108
|
-
exports.isFunction =
|
|
109
|
-
exports.isLength =
|
|
110
|
-
exports.isNil =
|
|
111
|
-
exports.isNotNil =
|
|
112
|
-
exports.isNull =
|
|
113
|
-
exports.
|
|
114
|
-
exports.isUndefined = isSymbol.isUndefined;
|
|
107
|
+
exports.isEqual = isFunction.isEqual;
|
|
108
|
+
exports.isFunction = isFunction.isFunction;
|
|
109
|
+
exports.isLength = isFunction.isLength;
|
|
110
|
+
exports.isNil = isFunction.isNil;
|
|
111
|
+
exports.isNotNil = isFunction.isNotNil;
|
|
112
|
+
exports.isNull = isFunction.isNull;
|
|
113
|
+
exports.isUndefined = isFunction.isUndefined;
|
|
115
114
|
exports.isPlainObject = isTypedArray.isPlainObject;
|
|
116
115
|
exports.isPrimitive = isTypedArray.isPrimitive;
|
|
117
116
|
exports.isTypedArray = isTypedArray.isTypedArray;
|
|
118
117
|
exports.isBoolean = predicate_index.isBoolean;
|
|
118
|
+
exports.isSymbol = predicate_index.isSymbol;
|
|
119
119
|
exports.camelCase = string_index.camelCase;
|
|
120
120
|
exports.capitalize = string_index.capitalize;
|
|
121
121
|
exports.kebabCase = string_index.kebabCase;
|
package/dist/predicate/index.js
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const isFunction = require('../_chunk/isFunction-D0hq6d.js');
|
|
6
6
|
const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
7
7
|
|
|
8
8
|
function isBoolean(x) {
|
|
9
9
|
return typeof x === 'boolean';
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
12
|
+
function isSymbol(value) {
|
|
13
|
+
return typeof value === 'symbol';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.isEqual = isFunction.isEqual;
|
|
17
|
+
exports.isFunction = isFunction.isFunction;
|
|
18
|
+
exports.isLength = isFunction.isLength;
|
|
19
|
+
exports.isNil = isFunction.isNil;
|
|
20
|
+
exports.isNotNil = isFunction.isNotNil;
|
|
21
|
+
exports.isNull = isFunction.isNull;
|
|
22
|
+
exports.isUndefined = isFunction.isUndefined;
|
|
20
23
|
exports.isPlainObject = isTypedArray.isPlainObject;
|
|
21
24
|
exports.isPrimitive = isTypedArray.isPrimitive;
|
|
22
25
|
exports.isTypedArray = isTypedArray.isTypedArray;
|
|
23
26
|
exports.isBoolean = isBoolean;
|
|
27
|
+
exports.isSymbol = isSymbol;
|
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.14.0-dev.
|
|
4
|
+
"version": "1.14.0-dev.412+bf33cfbc",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|