es-toolkit 1.36.0 → 1.37.0-dev.1243
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/CHANGELOG.md +15 -0
- package/dist/_chunk/isPlainObject-DINLyA.js +281 -0
- package/dist/_chunk/isPlainObject-Xaozpc.js +93 -0
- package/dist/_chunk/{isPromise-CxqI1v.js → isWeakSet-403Sh5.js} +65 -243
- package/dist/_chunk/{range-HnEIT7.js → range-DSpBDL.js} +0 -21
- package/dist/_chunk/snakeCase-BwvoPi.js +30 -0
- package/dist/_chunk/{unary-EIEhcF.js → unary-DzPndU.js} +0 -39
- package/dist/_chunk/{reverseString-BixeGz.js → upperFirst-C7IztG.js} +9 -52
- package/dist/_chunk/{zip-BJSrRi.js → zip-CIqPLd.js} +0 -102
- package/dist/array/index.js +103 -15
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/compareValues.mjs +0 -3
- package/dist/compat/array/initial.d.mts +16 -0
- package/dist/compat/array/initial.d.ts +16 -0
- package/dist/compat/array/initial.mjs +11 -0
- package/dist/compat/array/keyBy.d.mts +48 -0
- package/dist/compat/array/keyBy.d.ts +48 -0
- package/dist/compat/array/keyBy.mjs +21 -0
- package/dist/compat/array/sampleSize.d.mts +38 -0
- package/dist/compat/array/sampleSize.d.ts +38 -0
- package/dist/compat/array/sampleSize.mjs +18 -0
- package/dist/compat/array/shuffle.d.mts +22 -0
- package/dist/compat/array/shuffle.d.ts +22 -0
- package/dist/compat/array/shuffle.mjs +24 -0
- package/dist/compat/array/unzipWith.d.mts +78 -0
- package/dist/compat/array/unzipWith.d.ts +78 -0
- package/dist/compat/array/unzipWith.mjs +21 -0
- package/dist/compat/array/xor.d.mts +23 -0
- package/dist/compat/array/xor.d.ts +23 -0
- package/dist/compat/array/xor.mjs +30 -0
- package/dist/compat/array/xorBy.d.mts +108 -0
- package/dist/compat/array/xorBy.d.ts +108 -0
- package/dist/compat/array/xorBy.mjs +23 -0
- package/dist/compat/array/xorWith.d.mts +89 -0
- package/dist/compat/array/xorWith.d.ts +89 -0
- package/dist/compat/array/xorWith.mjs +21 -0
- package/dist/compat/compat.d.mts +25 -58
- package/dist/compat/compat.d.ts +25 -58
- package/dist/compat/compat.mjs +28 -63
- package/dist/compat/function/wrap.d.mts +27 -0
- package/dist/compat/function/wrap.d.ts +27 -0
- package/dist/compat/function/wrap.mjs +11 -0
- package/dist/compat/index.d.mts +25 -58
- package/dist/compat/index.d.ts +25 -58
- package/dist/compat/index.js +4688 -327
- package/dist/compat/index.mjs +28 -63
- package/dist/compat/object/omitBy.d.mts +22 -0
- package/dist/compat/object/omitBy.d.ts +22 -0
- package/dist/compat/object/omitBy.mjs +26 -0
- package/dist/compat/object/result.d.mts +33 -0
- package/dist/compat/object/result.d.ts +33 -0
- package/dist/compat/object/result.mjs +24 -0
- package/dist/compat/object/transform.d.mts +59 -0
- package/dist/compat/object/transform.d.ts +59 -0
- package/dist/compat/object/transform.mjs +30 -0
- package/dist/compat/util/toString.mjs +3 -0
- package/dist/function/index.js +39 -3
- package/dist/index.js +93 -92
- package/dist/math/index.js +22 -3
- package/dist/object/index.js +122 -15
- package/dist/object/toCamelCaseKeys.mjs +2 -12
- package/dist/object/toSnakeCaseKeys.mjs +1 -11
- package/dist/predicate/index.js +113 -30
- package/dist/string/index.js +37 -22
- package/dist/util/index.js +19 -4
- package/package.json +1 -1
- package/dist/_chunk/invariant-BfGFfr.js +0 -21
- package/dist/_chunk/toSnakeCaseKeys-DZO2eB.js +0 -4901
|
@@ -1,107 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const isPlainObject = require('./isPlainObject-Xaozpc.js');
|
|
3
4
|
const noop = require('./noop-2IwLUk.js');
|
|
4
5
|
|
|
5
|
-
function
|
|
6
|
-
return value
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function isTypedArray(x) {
|
|
10
|
-
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function getSymbols(object) {
|
|
14
|
-
return Object.getOwnPropertySymbols(object).filter(symbol => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getTag(value) {
|
|
18
|
-
if (value == null) {
|
|
19
|
-
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
20
|
-
}
|
|
21
|
-
return Object.prototype.toString.call(value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const regexpTag = '[object RegExp]';
|
|
25
|
-
const stringTag = '[object String]';
|
|
26
|
-
const numberTag = '[object Number]';
|
|
27
|
-
const booleanTag = '[object Boolean]';
|
|
28
|
-
const argumentsTag = '[object Arguments]';
|
|
29
|
-
const symbolTag = '[object Symbol]';
|
|
30
|
-
const dateTag = '[object Date]';
|
|
31
|
-
const mapTag = '[object Map]';
|
|
32
|
-
const setTag = '[object Set]';
|
|
33
|
-
const arrayTag = '[object Array]';
|
|
34
|
-
const functionTag = '[object Function]';
|
|
35
|
-
const arrayBufferTag = '[object ArrayBuffer]';
|
|
36
|
-
const objectTag = '[object Object]';
|
|
37
|
-
const errorTag = '[object Error]';
|
|
38
|
-
const dataViewTag = '[object DataView]';
|
|
39
|
-
const uint8ArrayTag = '[object Uint8Array]';
|
|
40
|
-
const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
|
|
41
|
-
const uint16ArrayTag = '[object Uint16Array]';
|
|
42
|
-
const uint32ArrayTag = '[object Uint32Array]';
|
|
43
|
-
const bigUint64ArrayTag = '[object BigUint64Array]';
|
|
44
|
-
const int8ArrayTag = '[object Int8Array]';
|
|
45
|
-
const int16ArrayTag = '[object Int16Array]';
|
|
46
|
-
const int32ArrayTag = '[object Int32Array]';
|
|
47
|
-
const bigInt64ArrayTag = '[object BigInt64Array]';
|
|
48
|
-
const float32ArrayTag = '[object Float32Array]';
|
|
49
|
-
const float64ArrayTag = '[object Float64Array]';
|
|
50
|
-
|
|
51
|
-
function isPlainObject(value) {
|
|
52
|
-
if (!value || typeof value !== 'object') {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
const proto = Object.getPrototypeOf(value);
|
|
56
|
-
const hasObjectPrototype = proto === null ||
|
|
57
|
-
proto === Object.prototype ||
|
|
58
|
-
Object.getPrototypeOf(proto) === null;
|
|
59
|
-
if (!hasObjectPrototype) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function isLength(value) {
|
|
66
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function eq(value, other) {
|
|
70
|
-
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isNil(x) {
|
|
74
|
-
return x == null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function isNull(x) {
|
|
78
|
-
return x === null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function isUndefined(x) {
|
|
82
|
-
return x === undefined;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function isSymbol(value) {
|
|
86
|
-
return typeof value === 'symbol';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function isFunction(value) {
|
|
90
|
-
return typeof value === 'function';
|
|
6
|
+
function isArrayBuffer(value) {
|
|
7
|
+
return value instanceof ArrayBuffer;
|
|
91
8
|
}
|
|
92
9
|
|
|
93
10
|
function isBuffer(x) {
|
|
94
11
|
return typeof Buffer !== 'undefined' && Buffer.isBuffer(x);
|
|
95
12
|
}
|
|
96
13
|
|
|
97
|
-
function isArrayBuffer(value) {
|
|
98
|
-
return value instanceof ArrayBuffer;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
14
|
function isDate(value) {
|
|
102
15
|
return value instanceof Date;
|
|
103
16
|
}
|
|
104
17
|
|
|
18
|
+
function eq(value, other) {
|
|
19
|
+
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
20
|
+
}
|
|
21
|
+
|
|
105
22
|
function isEqualWith(a, b, areValuesEqual) {
|
|
106
23
|
return isEqualWithImpl(a, b, undefined, undefined, undefined, undefined, areValuesEqual);
|
|
107
24
|
}
|
|
@@ -136,33 +53,33 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
136
53
|
if (Object.is(a, b)) {
|
|
137
54
|
return true;
|
|
138
55
|
}
|
|
139
|
-
let aTag = getTag(a);
|
|
140
|
-
let bTag = getTag(b);
|
|
141
|
-
if (aTag === argumentsTag) {
|
|
142
|
-
aTag = objectTag;
|
|
56
|
+
let aTag = isPlainObject.getTag(a);
|
|
57
|
+
let bTag = isPlainObject.getTag(b);
|
|
58
|
+
if (aTag === isPlainObject.argumentsTag) {
|
|
59
|
+
aTag = isPlainObject.objectTag;
|
|
143
60
|
}
|
|
144
|
-
if (bTag === argumentsTag) {
|
|
145
|
-
bTag = objectTag;
|
|
61
|
+
if (bTag === isPlainObject.argumentsTag) {
|
|
62
|
+
bTag = isPlainObject.objectTag;
|
|
146
63
|
}
|
|
147
64
|
if (aTag !== bTag) {
|
|
148
65
|
return false;
|
|
149
66
|
}
|
|
150
67
|
switch (aTag) {
|
|
151
|
-
case stringTag:
|
|
68
|
+
case isPlainObject.stringTag:
|
|
152
69
|
return a.toString() === b.toString();
|
|
153
|
-
case numberTag: {
|
|
70
|
+
case isPlainObject.numberTag: {
|
|
154
71
|
const x = a.valueOf();
|
|
155
72
|
const y = b.valueOf();
|
|
156
73
|
return eq(x, y);
|
|
157
74
|
}
|
|
158
|
-
case booleanTag:
|
|
159
|
-
case dateTag:
|
|
160
|
-
case symbolTag:
|
|
75
|
+
case isPlainObject.booleanTag:
|
|
76
|
+
case isPlainObject.dateTag:
|
|
77
|
+
case isPlainObject.symbolTag:
|
|
161
78
|
return Object.is(a.valueOf(), b.valueOf());
|
|
162
|
-
case regexpTag: {
|
|
79
|
+
case isPlainObject.regexpTag: {
|
|
163
80
|
return a.source === b.source && a.flags === b.flags;
|
|
164
81
|
}
|
|
165
|
-
case functionTag: {
|
|
82
|
+
case isPlainObject.functionTag: {
|
|
166
83
|
return a === b;
|
|
167
84
|
}
|
|
168
85
|
}
|
|
@@ -176,7 +93,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
176
93
|
stack.set(b, a);
|
|
177
94
|
try {
|
|
178
95
|
switch (aTag) {
|
|
179
|
-
case mapTag: {
|
|
96
|
+
case isPlainObject.mapTag: {
|
|
180
97
|
if (a.size !== b.size) {
|
|
181
98
|
return false;
|
|
182
99
|
}
|
|
@@ -187,7 +104,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
187
104
|
}
|
|
188
105
|
return true;
|
|
189
106
|
}
|
|
190
|
-
case setTag: {
|
|
107
|
+
case isPlainObject.setTag: {
|
|
191
108
|
if (a.size !== b.size) {
|
|
192
109
|
return false;
|
|
193
110
|
}
|
|
@@ -205,18 +122,18 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
205
122
|
}
|
|
206
123
|
return true;
|
|
207
124
|
}
|
|
208
|
-
case arrayTag:
|
|
209
|
-
case uint8ArrayTag:
|
|
210
|
-
case uint8ClampedArrayTag:
|
|
211
|
-
case uint16ArrayTag:
|
|
212
|
-
case uint32ArrayTag:
|
|
213
|
-
case bigUint64ArrayTag:
|
|
214
|
-
case int8ArrayTag:
|
|
215
|
-
case int16ArrayTag:
|
|
216
|
-
case int32ArrayTag:
|
|
217
|
-
case bigInt64ArrayTag:
|
|
218
|
-
case float32ArrayTag:
|
|
219
|
-
case float64ArrayTag: {
|
|
125
|
+
case isPlainObject.arrayTag:
|
|
126
|
+
case isPlainObject.uint8ArrayTag:
|
|
127
|
+
case isPlainObject.uint8ClampedArrayTag:
|
|
128
|
+
case isPlainObject.uint16ArrayTag:
|
|
129
|
+
case isPlainObject.uint32ArrayTag:
|
|
130
|
+
case isPlainObject.bigUint64ArrayTag:
|
|
131
|
+
case isPlainObject.int8ArrayTag:
|
|
132
|
+
case isPlainObject.int16ArrayTag:
|
|
133
|
+
case isPlainObject.int32ArrayTag:
|
|
134
|
+
case isPlainObject.bigInt64ArrayTag:
|
|
135
|
+
case isPlainObject.float32ArrayTag:
|
|
136
|
+
case isPlainObject.float64ArrayTag: {
|
|
220
137
|
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
|
|
221
138
|
return false;
|
|
222
139
|
}
|
|
@@ -230,29 +147,29 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
230
147
|
}
|
|
231
148
|
return true;
|
|
232
149
|
}
|
|
233
|
-
case arrayBufferTag: {
|
|
150
|
+
case isPlainObject.arrayBufferTag: {
|
|
234
151
|
if (a.byteLength !== b.byteLength) {
|
|
235
152
|
return false;
|
|
236
153
|
}
|
|
237
154
|
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
238
155
|
}
|
|
239
|
-
case dataViewTag: {
|
|
156
|
+
case isPlainObject.dataViewTag: {
|
|
240
157
|
if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
|
|
241
158
|
return false;
|
|
242
159
|
}
|
|
243
160
|
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
244
161
|
}
|
|
245
|
-
case errorTag: {
|
|
162
|
+
case isPlainObject.errorTag: {
|
|
246
163
|
return a.name === b.name && a.message === b.message;
|
|
247
164
|
}
|
|
248
|
-
case objectTag: {
|
|
165
|
+
case isPlainObject.objectTag: {
|
|
249
166
|
const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) ||
|
|
250
|
-
(isPlainObject(a) && isPlainObject(b));
|
|
167
|
+
(isPlainObject.isPlainObject(a) && isPlainObject.isPlainObject(b));
|
|
251
168
|
if (!areEqualInstances) {
|
|
252
169
|
return false;
|
|
253
170
|
}
|
|
254
|
-
const aKeys = [...Object.keys(a), ...getSymbols(a)];
|
|
255
|
-
const bKeys = [...Object.keys(b), ...getSymbols(b)];
|
|
171
|
+
const aKeys = [...Object.keys(a), ...isPlainObject.getSymbols(a)];
|
|
172
|
+
const bKeys = [...Object.keys(b), ...isPlainObject.getSymbols(b)];
|
|
256
173
|
if (aKeys.length !== bKeys.length) {
|
|
257
174
|
return false;
|
|
258
175
|
}
|
|
@@ -280,163 +197,68 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
280
197
|
}
|
|
281
198
|
}
|
|
282
199
|
|
|
283
|
-
function
|
|
284
|
-
return
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function isRegExp(value) {
|
|
288
|
-
return value instanceof RegExp;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function isSet(value) {
|
|
292
|
-
return value instanceof Set;
|
|
200
|
+
function isEqual(a, b) {
|
|
201
|
+
return isEqualWith(a, b, noop.noop);
|
|
293
202
|
}
|
|
294
203
|
|
|
295
|
-
function
|
|
296
|
-
return value
|
|
204
|
+
function isFunction(value) {
|
|
205
|
+
return typeof value === 'function';
|
|
297
206
|
}
|
|
298
207
|
|
|
299
|
-
function
|
|
300
|
-
return value
|
|
208
|
+
function isLength(value) {
|
|
209
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
301
210
|
}
|
|
302
211
|
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
return x instanceof Blob;
|
|
212
|
+
function isMap(value) {
|
|
213
|
+
return value instanceof Map;
|
|
308
214
|
}
|
|
309
215
|
|
|
310
|
-
function
|
|
311
|
-
return
|
|
216
|
+
function isNil(x) {
|
|
217
|
+
return x == null;
|
|
312
218
|
}
|
|
313
219
|
|
|
314
|
-
function
|
|
315
|
-
return
|
|
220
|
+
function isNull(x) {
|
|
221
|
+
return x === null;
|
|
316
222
|
}
|
|
317
223
|
|
|
318
|
-
function
|
|
319
|
-
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
return isBlob(x) && x instanceof File;
|
|
224
|
+
function isRegExp(value) {
|
|
225
|
+
return value instanceof RegExp;
|
|
323
226
|
}
|
|
324
227
|
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
try {
|
|
330
|
-
JSON.parse(value);
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
catch {
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
228
|
+
function isSet(value) {
|
|
229
|
+
return value instanceof Set;
|
|
336
230
|
}
|
|
337
231
|
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
case 'object': {
|
|
341
|
-
return value === null || isJSONArray(value) || isJSONObject(value);
|
|
342
|
-
}
|
|
343
|
-
case 'string':
|
|
344
|
-
case 'number':
|
|
345
|
-
case 'boolean': {
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
default: {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
function isJSONArray(value) {
|
|
354
|
-
if (!Array.isArray(value)) {
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
return value.every(item => isJSONValue(item));
|
|
358
|
-
}
|
|
359
|
-
function isJSONObject(obj) {
|
|
360
|
-
if (!isPlainObject(obj)) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
const keys = Reflect.ownKeys(obj);
|
|
364
|
-
for (let i = 0; i < keys.length; i++) {
|
|
365
|
-
const key = keys[i];
|
|
366
|
-
const value = obj[key];
|
|
367
|
-
if (typeof key !== 'string') {
|
|
368
|
-
return false;
|
|
369
|
-
}
|
|
370
|
-
if (!isJSONValue(value)) {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return true;
|
|
232
|
+
function isSymbol(value) {
|
|
233
|
+
return typeof value === 'symbol';
|
|
375
234
|
}
|
|
376
235
|
|
|
377
|
-
function
|
|
378
|
-
return
|
|
236
|
+
function isUndefined(x) {
|
|
237
|
+
return x === undefined;
|
|
379
238
|
}
|
|
380
239
|
|
|
381
|
-
function
|
|
382
|
-
return
|
|
240
|
+
function isWeakMap(value) {
|
|
241
|
+
return value instanceof WeakMap;
|
|
383
242
|
}
|
|
384
243
|
|
|
385
|
-
function
|
|
386
|
-
return value instanceof
|
|
244
|
+
function isWeakSet(value) {
|
|
245
|
+
return value instanceof WeakSet;
|
|
387
246
|
}
|
|
388
247
|
|
|
389
|
-
exports.argumentsTag = argumentsTag;
|
|
390
|
-
exports.arrayBufferTag = arrayBufferTag;
|
|
391
|
-
exports.arrayTag = arrayTag;
|
|
392
|
-
exports.booleanTag = booleanTag;
|
|
393
|
-
exports.dataViewTag = dataViewTag;
|
|
394
|
-
exports.dateTag = dateTag;
|
|
395
248
|
exports.eq = eq;
|
|
396
|
-
exports.float32ArrayTag = float32ArrayTag;
|
|
397
|
-
exports.float64ArrayTag = float64ArrayTag;
|
|
398
|
-
exports.getSymbols = getSymbols;
|
|
399
|
-
exports.getTag = getTag;
|
|
400
|
-
exports.int16ArrayTag = int16ArrayTag;
|
|
401
|
-
exports.int32ArrayTag = int32ArrayTag;
|
|
402
|
-
exports.int8ArrayTag = int8ArrayTag;
|
|
403
249
|
exports.isArrayBuffer = isArrayBuffer;
|
|
404
|
-
exports.isBlob = isBlob;
|
|
405
|
-
exports.isBrowser = isBrowser;
|
|
406
250
|
exports.isBuffer = isBuffer;
|
|
407
251
|
exports.isDate = isDate;
|
|
408
252
|
exports.isEqual = isEqual;
|
|
409
253
|
exports.isEqualWith = isEqualWith;
|
|
410
|
-
exports.isFile = isFile;
|
|
411
254
|
exports.isFunction = isFunction;
|
|
412
|
-
exports.isJSON = isJSON;
|
|
413
|
-
exports.isJSONArray = isJSONArray;
|
|
414
|
-
exports.isJSONObject = isJSONObject;
|
|
415
|
-
exports.isJSONValue = isJSONValue;
|
|
416
255
|
exports.isLength = isLength;
|
|
417
256
|
exports.isMap = isMap;
|
|
418
257
|
exports.isNil = isNil;
|
|
419
|
-
exports.isNode = isNode;
|
|
420
|
-
exports.isNotNil = isNotNil;
|
|
421
258
|
exports.isNull = isNull;
|
|
422
|
-
exports.isPlainObject = isPlainObject;
|
|
423
|
-
exports.isPrimitive = isPrimitive;
|
|
424
|
-
exports.isPromise = isPromise;
|
|
425
259
|
exports.isRegExp = isRegExp;
|
|
426
260
|
exports.isSet = isSet;
|
|
427
261
|
exports.isSymbol = isSymbol;
|
|
428
|
-
exports.isTypedArray = isTypedArray;
|
|
429
262
|
exports.isUndefined = isUndefined;
|
|
430
263
|
exports.isWeakMap = isWeakMap;
|
|
431
264
|
exports.isWeakSet = isWeakSet;
|
|
432
|
-
exports.mapTag = mapTag;
|
|
433
|
-
exports.numberTag = numberTag;
|
|
434
|
-
exports.objectTag = objectTag;
|
|
435
|
-
exports.regexpTag = regexpTag;
|
|
436
|
-
exports.setTag = setTag;
|
|
437
|
-
exports.stringTag = stringTag;
|
|
438
|
-
exports.symbolTag = symbolTag;
|
|
439
|
-
exports.uint16ArrayTag = uint16ArrayTag;
|
|
440
|
-
exports.uint32ArrayTag = uint32ArrayTag;
|
|
441
|
-
exports.uint8ArrayTag = uint8ArrayTag;
|
|
442
|
-
exports.uint8ClampedArrayTag = uint8ClampedArrayTag;
|
|
@@ -35,25 +35,6 @@ function meanBy(items, getValue) {
|
|
|
35
35
|
return mean(nums);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function median(nums) {
|
|
39
|
-
if (nums.length === 0) {
|
|
40
|
-
return NaN;
|
|
41
|
-
}
|
|
42
|
-
const sorted = nums.slice().sort((a, b) => a - b);
|
|
43
|
-
const middleIndex = Math.floor(sorted.length / 2);
|
|
44
|
-
if (sorted.length % 2 === 0) {
|
|
45
|
-
return (sorted[middleIndex - 1] + sorted[middleIndex]) / 2;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return sorted[middleIndex];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function medianBy(items, getValue) {
|
|
53
|
-
const nums = items.map(x => getValue(x));
|
|
54
|
-
return median(nums);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
38
|
function range(start, end, step = 1) {
|
|
58
39
|
if (end == null) {
|
|
59
40
|
end = start;
|
|
@@ -74,7 +55,5 @@ exports.clamp = clamp;
|
|
|
74
55
|
exports.inRange = inRange;
|
|
75
56
|
exports.mean = mean;
|
|
76
57
|
exports.meanBy = meanBy;
|
|
77
|
-
exports.median = median;
|
|
78
|
-
exports.medianBy = medianBy;
|
|
79
58
|
exports.range = range;
|
|
80
59
|
exports.sum = sum;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function capitalize(str) {
|
|
4
|
+
return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
8
|
+
function words(str) {
|
|
9
|
+
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function camelCase(str) {
|
|
13
|
+
const words$1 = words(str);
|
|
14
|
+
if (words$1.length === 0) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
const [first, ...rest] = words$1;
|
|
18
|
+
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function snakeCase(str) {
|
|
22
|
+
const words$1 = words(str);
|
|
23
|
+
return words$1.map(word => word.toLowerCase()).join('_');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.CASE_SPLIT_PATTERN = CASE_SPLIT_PATTERN;
|
|
27
|
+
exports.camelCase = camelCase;
|
|
28
|
+
exports.capitalize = capitalize;
|
|
29
|
+
exports.snakeCase = snakeCase;
|
|
30
|
+
exports.words = words;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const delay = require('./delay-_VMfFa.js');
|
|
4
|
-
|
|
5
3
|
function after(n, func) {
|
|
6
4
|
if (!Number.isInteger(n) || n < 0) {
|
|
7
5
|
throw new Error(`n must be a non-negative integer.`);
|
|
@@ -21,8 +19,6 @@ function ary(func, n) {
|
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
async function asyncNoop() { }
|
|
25
|
-
|
|
26
22
|
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
27
23
|
let pendingThis = undefined;
|
|
28
24
|
let pendingArgs = null;
|
|
@@ -187,46 +183,12 @@ function rest(func, startIndex = func.length - 1) {
|
|
|
187
183
|
};
|
|
188
184
|
}
|
|
189
185
|
|
|
190
|
-
const DEFAULT_DELAY = 0;
|
|
191
|
-
const DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
|
|
192
|
-
async function retry(func, _options) {
|
|
193
|
-
let delay$1;
|
|
194
|
-
let retries;
|
|
195
|
-
let signal;
|
|
196
|
-
if (typeof _options === 'number') {
|
|
197
|
-
delay$1 = DEFAULT_DELAY;
|
|
198
|
-
retries = _options;
|
|
199
|
-
signal = undefined;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
delay$1 = _options?.delay ?? DEFAULT_DELAY;
|
|
203
|
-
retries = _options?.retries ?? DEFAULT_RETRIES;
|
|
204
|
-
signal = _options?.signal;
|
|
205
|
-
}
|
|
206
|
-
let error;
|
|
207
|
-
for (let attempts = 0; attempts < retries; attempts++) {
|
|
208
|
-
if (signal?.aborted) {
|
|
209
|
-
throw error ?? new Error(`The retry operation was aborted due to an abort signal.`);
|
|
210
|
-
}
|
|
211
|
-
try {
|
|
212
|
-
return await func();
|
|
213
|
-
}
|
|
214
|
-
catch (err) {
|
|
215
|
-
error = err;
|
|
216
|
-
const currentDelay = typeof delay$1 === 'function' ? delay$1(attempts) : delay$1;
|
|
217
|
-
await delay.delay(currentDelay);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
throw error;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
186
|
function unary(func) {
|
|
224
187
|
return ary(func, 1);
|
|
225
188
|
}
|
|
226
189
|
|
|
227
190
|
exports.after = after;
|
|
228
191
|
exports.ary = ary;
|
|
229
|
-
exports.asyncNoop = asyncNoop;
|
|
230
192
|
exports.debounce = debounce;
|
|
231
193
|
exports.flow = flow;
|
|
232
194
|
exports.flowRight = flowRight;
|
|
@@ -239,5 +201,4 @@ exports.partialImpl = partialImpl;
|
|
|
239
201
|
exports.partialRight = partialRight;
|
|
240
202
|
exports.partialRightImpl = partialRightImpl;
|
|
241
203
|
exports.rest = rest;
|
|
242
|
-
exports.retry = retry;
|
|
243
204
|
exports.unary = unary;
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
8
|
-
function words(str) {
|
|
9
|
-
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function camelCase(str) {
|
|
13
|
-
const words$1 = words(str);
|
|
14
|
-
if (words$1.length === 0) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
const [first, ...rest] = words$1;
|
|
18
|
-
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
|
-
}
|
|
3
|
+
const snakeCase = require('./snakeCase-BwvoPi.js');
|
|
20
4
|
|
|
21
5
|
const deburrMap = new Map(Object.entries({
|
|
22
6
|
Æ: 'Ae',
|
|
@@ -78,13 +62,13 @@ function escapeRegExp(str) {
|
|
|
78
62
|
}
|
|
79
63
|
|
|
80
64
|
function kebabCase(str) {
|
|
81
|
-
const words
|
|
82
|
-
return words
|
|
65
|
+
const words = snakeCase.words(str);
|
|
66
|
+
return words.map(word => word.toLowerCase()).join('-');
|
|
83
67
|
}
|
|
84
68
|
|
|
85
69
|
function lowerCase(str) {
|
|
86
|
-
const words
|
|
87
|
-
return words
|
|
70
|
+
const words = snakeCase.words(str);
|
|
71
|
+
return words.map(word => word.toLowerCase()).join(' ');
|
|
88
72
|
}
|
|
89
73
|
|
|
90
74
|
function lowerFirst(str) {
|
|
@@ -95,11 +79,6 @@ function pad(str, length, chars = ' ') {
|
|
|
95
79
|
return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
|
|
96
80
|
}
|
|
97
81
|
|
|
98
|
-
function snakeCase(str) {
|
|
99
|
-
const words$1 = words(str);
|
|
100
|
-
return words$1.map(word => word.toLowerCase()).join('_');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
82
|
function trimEnd(str, chars) {
|
|
104
83
|
if (chars === undefined) {
|
|
105
84
|
return str.trimEnd();
|
|
@@ -164,11 +143,11 @@ function unescape(str) {
|
|
|
164
143
|
}
|
|
165
144
|
|
|
166
145
|
function upperCase(str) {
|
|
167
|
-
const words
|
|
146
|
+
const words = snakeCase.words(str);
|
|
168
147
|
let result = '';
|
|
169
|
-
for (let i = 0; i < words
|
|
170
|
-
result += words
|
|
171
|
-
if (i < words
|
|
148
|
+
for (let i = 0; i < words.length; i++) {
|
|
149
|
+
result += words[i].toUpperCase();
|
|
150
|
+
if (i < words.length - 1) {
|
|
172
151
|
result += ' ';
|
|
173
152
|
}
|
|
174
153
|
}
|
|
@@ -179,24 +158,6 @@ function upperFirst(str) {
|
|
|
179
158
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
180
159
|
}
|
|
181
160
|
|
|
182
|
-
function constantCase(str) {
|
|
183
|
-
const words$1 = words(str);
|
|
184
|
-
return words$1.map(word => word.toUpperCase()).join('_');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function pascalCase(str) {
|
|
188
|
-
const words$1 = words(str);
|
|
189
|
-
return words$1.map(word => capitalize(word)).join('');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function reverseString(value) {
|
|
193
|
-
return [...value].reverse().join('');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
exports.CASE_SPLIT_PATTERN = CASE_SPLIT_PATTERN;
|
|
197
|
-
exports.camelCase = camelCase;
|
|
198
|
-
exports.capitalize = capitalize;
|
|
199
|
-
exports.constantCase = constantCase;
|
|
200
161
|
exports.deburr = deburr;
|
|
201
162
|
exports.escape = escape;
|
|
202
163
|
exports.escapeRegExp = escapeRegExp;
|
|
@@ -204,13 +165,9 @@ exports.kebabCase = kebabCase;
|
|
|
204
165
|
exports.lowerCase = lowerCase;
|
|
205
166
|
exports.lowerFirst = lowerFirst;
|
|
206
167
|
exports.pad = pad;
|
|
207
|
-
exports.pascalCase = pascalCase;
|
|
208
|
-
exports.reverseString = reverseString;
|
|
209
|
-
exports.snakeCase = snakeCase;
|
|
210
168
|
exports.trim = trim;
|
|
211
169
|
exports.trimEnd = trimEnd;
|
|
212
170
|
exports.trimStart = trimStart;
|
|
213
171
|
exports.unescape = unescape;
|
|
214
172
|
exports.upperCase = upperCase;
|
|
215
173
|
exports.upperFirst = upperFirst;
|
|
216
|
-
exports.words = words;
|