es-toolkit 1.23.0-dev.750 → 1.23.0-dev.755
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/array/every.mjs +4 -5
- package/dist/compat/array/filter.mjs +4 -5
- package/dist/compat/array/find.mjs +4 -5
- package/dist/compat/index.d.mts +5 -5
- package/dist/compat/index.d.ts +5 -5
- package/dist/compat/index.js +47 -50
- package/dist/compat/index.mjs +5 -5
- package/dist/compat/predicate/isEqualWith.mjs +1 -1
- package/dist/compat/string/upperCase.mjs +0 -1
- package/dist/compat/util/defaultTo.d.mts +5 -7
- package/dist/compat/util/defaultTo.d.ts +5 -7
- package/dist/compat/util/times.d.mts +8 -12
- package/dist/compat/util/times.d.ts +8 -12
- package/dist/compat/util/times.mjs +2 -2
- package/dist/compat/util/toLength.d.mts +5 -3
- package/dist/compat/util/toLength.d.ts +5 -3
- package/dist/function/index.d.mts +10 -10
- package/dist/function/index.d.ts +10 -10
- package/dist/function/index.js +34 -34
- package/dist/function/index.mjs +10 -10
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +13 -13
- package/dist/index.mjs +10 -10
- package/package.json +2 -2
- package/dist/_chunk/{flowRight-Cf9ldK.js → unary-BZ5Ixo.js} +27 -27
|
@@ -17,11 +17,10 @@ function every(source, doesMatch) {
|
|
|
17
17
|
switch (typeof doesMatch) {
|
|
18
18
|
case 'function': {
|
|
19
19
|
if (!Array.isArray(source)) {
|
|
20
|
-
const
|
|
21
|
-
for (let i = 0; i <
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const value = entry[1];
|
|
20
|
+
const keys = Object.keys(source);
|
|
21
|
+
for (let i = 0; i < keys.length; i++) {
|
|
22
|
+
const key = keys[i];
|
|
23
|
+
const value = source[key];
|
|
25
24
|
if (!doesMatch(value, key, source)) {
|
|
26
25
|
return false;
|
|
27
26
|
}
|
|
@@ -13,11 +13,10 @@ function filter(source, predicate) {
|
|
|
13
13
|
case 'function': {
|
|
14
14
|
if (!Array.isArray(source)) {
|
|
15
15
|
const result = [];
|
|
16
|
-
const
|
|
17
|
-
for (let i = 0; i <
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const value = entry[1];
|
|
16
|
+
const keys = Object.keys(source);
|
|
17
|
+
for (let i = 0; i < keys.length; i++) {
|
|
18
|
+
const key = keys[i];
|
|
19
|
+
const value = source[key];
|
|
21
20
|
if (predicate(value, key, source)) {
|
|
22
21
|
result.push(value);
|
|
23
22
|
}
|
|
@@ -10,11 +10,10 @@ function find(source, doesMatch) {
|
|
|
10
10
|
switch (typeof doesMatch) {
|
|
11
11
|
case 'function': {
|
|
12
12
|
if (!Array.isArray(source)) {
|
|
13
|
-
const
|
|
14
|
-
for (let i = 0; i <
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const value = entry[1];
|
|
13
|
+
const keys = Object.keys(source);
|
|
14
|
+
for (let i = 0; i < keys.length; i++) {
|
|
15
|
+
const key = keys[i];
|
|
16
|
+
const value = source[key];
|
|
18
17
|
if (doesMatch(value, key, source)) {
|
|
19
18
|
return value;
|
|
20
19
|
}
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -46,13 +46,13 @@ export { zipWith } from '../array/zipWith.mjs';
|
|
|
46
46
|
export { AbortError } from '../error/AbortError.mjs';
|
|
47
47
|
export { TimeoutError } from '../error/TimeoutError.mjs';
|
|
48
48
|
export { after } from '../function/after.mjs';
|
|
49
|
+
export { MemoizeCache, memoize } from '../function/memoize.mjs';
|
|
50
|
+
export { negate } from '../function/negate.mjs';
|
|
49
51
|
export { noop } from '../function/noop.mjs';
|
|
50
52
|
export { once } from '../function/once.mjs';
|
|
51
|
-
export { negate } from '../function/negate.mjs';
|
|
52
|
-
export { MemoizeCache, memoize } from '../function/memoize.mjs';
|
|
53
|
-
export { unary } from '../function/unary.mjs';
|
|
54
53
|
export { partial } from '../function/partial.mjs';
|
|
55
54
|
export { partialRight } from '../function/partialRight.mjs';
|
|
55
|
+
export { unary } from '../function/unary.mjs';
|
|
56
56
|
export { mean } from '../math/mean.mjs';
|
|
57
57
|
export { meanBy } from '../math/meanBy.mjs';
|
|
58
58
|
export { randomInt } from '../math/randomInt.mjs';
|
|
@@ -95,8 +95,8 @@ export { chunk } from './array/chunk.mjs';
|
|
|
95
95
|
export { concat } from './array/concat.mjs';
|
|
96
96
|
export { difference } from './array/difference.mjs';
|
|
97
97
|
export { drop } from './array/drop.mjs';
|
|
98
|
-
export { dropWhile } from './array/dropWhile.mjs';
|
|
99
98
|
export { dropRightWhile } from './array/dropRightWhile.mjs';
|
|
99
|
+
export { dropWhile } from './array/dropWhile.mjs';
|
|
100
100
|
export { every } from './array/every.mjs';
|
|
101
101
|
export { fill } from './array/fill.mjs';
|
|
102
102
|
export { filter } from './array/filter.mjs';
|
|
@@ -202,6 +202,7 @@ export { trim } from './string/trim.mjs';
|
|
|
202
202
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
203
203
|
export { trimStart } from './string/trimStart.mjs';
|
|
204
204
|
export { constant } from './util/constant.mjs';
|
|
205
|
+
export { defaultTo } from './util/defaultTo.mjs';
|
|
205
206
|
export { eq } from './util/eq.mjs';
|
|
206
207
|
export { times } from './util/times.mjs';
|
|
207
208
|
export { toFinite } from './util/toFinite.mjs';
|
|
@@ -210,4 +211,3 @@ export { toLength } from './util/toLength.mjs';
|
|
|
210
211
|
export { toNumber } from './util/toNumber.mjs';
|
|
211
212
|
export { toPath } from './util/toPath.mjs';
|
|
212
213
|
export { toString } from './util/toString.mjs';
|
|
213
|
-
export { defaultTo } from './util/defaultTo.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -46,13 +46,13 @@ export { zipWith } from '../array/zipWith.js';
|
|
|
46
46
|
export { AbortError } from '../error/AbortError.js';
|
|
47
47
|
export { TimeoutError } from '../error/TimeoutError.js';
|
|
48
48
|
export { after } from '../function/after.js';
|
|
49
|
+
export { MemoizeCache, memoize } from '../function/memoize.js';
|
|
50
|
+
export { negate } from '../function/negate.js';
|
|
49
51
|
export { noop } from '../function/noop.js';
|
|
50
52
|
export { once } from '../function/once.js';
|
|
51
|
-
export { negate } from '../function/negate.js';
|
|
52
|
-
export { MemoizeCache, memoize } from '../function/memoize.js';
|
|
53
|
-
export { unary } from '../function/unary.js';
|
|
54
53
|
export { partial } from '../function/partial.js';
|
|
55
54
|
export { partialRight } from '../function/partialRight.js';
|
|
55
|
+
export { unary } from '../function/unary.js';
|
|
56
56
|
export { mean } from '../math/mean.js';
|
|
57
57
|
export { meanBy } from '../math/meanBy.js';
|
|
58
58
|
export { randomInt } from '../math/randomInt.js';
|
|
@@ -95,8 +95,8 @@ export { chunk } from './array/chunk.js';
|
|
|
95
95
|
export { concat } from './array/concat.js';
|
|
96
96
|
export { difference } from './array/difference.js';
|
|
97
97
|
export { drop } from './array/drop.js';
|
|
98
|
-
export { dropWhile } from './array/dropWhile.js';
|
|
99
98
|
export { dropRightWhile } from './array/dropRightWhile.js';
|
|
99
|
+
export { dropWhile } from './array/dropWhile.js';
|
|
100
100
|
export { every } from './array/every.js';
|
|
101
101
|
export { fill } from './array/fill.js';
|
|
102
102
|
export { filter } from './array/filter.js';
|
|
@@ -202,6 +202,7 @@ export { trim } from './string/trim.js';
|
|
|
202
202
|
export { trimEnd } from './string/trimEnd.js';
|
|
203
203
|
export { trimStart } from './string/trimStart.js';
|
|
204
204
|
export { constant } from './util/constant.js';
|
|
205
|
+
export { defaultTo } from './util/defaultTo.js';
|
|
205
206
|
export { eq } from './util/eq.js';
|
|
206
207
|
export { times } from './util/times.js';
|
|
207
208
|
export { toFinite } from './util/toFinite.js';
|
|
@@ -210,4 +211,3 @@ export { toLength } from './util/toLength.js';
|
|
|
210
211
|
export { toNumber } from './util/toNumber.js';
|
|
211
212
|
export { toPath } from './util/toPath.js';
|
|
212
213
|
export { toString } from './util/toString.js';
|
|
213
|
-
export { defaultTo } from './util/defaultTo.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const zipWith = require('../_chunk/zipWith-CV0XAX.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
|
-
const
|
|
7
|
+
const unary = require('../_chunk/unary-BZ5Ixo.js');
|
|
8
8
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
9
9
|
const sumBy = require('../_chunk/sumBy-BkErWJ.js');
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
@@ -376,44 +376,44 @@ function matchesProperty(property, source) {
|
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
function
|
|
379
|
+
function dropRightWhile(arr, predicate) {
|
|
380
380
|
switch (typeof predicate) {
|
|
381
381
|
case 'function': {
|
|
382
|
-
return zipWith.
|
|
382
|
+
return zipWith.dropRightWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
|
|
383
383
|
}
|
|
384
384
|
case 'object': {
|
|
385
385
|
if (Array.isArray(predicate) && predicate.length === 2) {
|
|
386
386
|
const key = predicate[0];
|
|
387
387
|
const value = predicate[1];
|
|
388
|
-
return zipWith.
|
|
388
|
+
return zipWith.dropRightWhile(arr, matchesProperty(key, value));
|
|
389
389
|
}
|
|
390
390
|
else {
|
|
391
|
-
return zipWith.
|
|
391
|
+
return zipWith.dropRightWhile(arr, matches(predicate));
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
case 'string': {
|
|
395
|
-
return zipWith.
|
|
395
|
+
return zipWith.dropRightWhile(arr, property(predicate));
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
function
|
|
400
|
+
function dropWhile(arr, predicate) {
|
|
401
401
|
switch (typeof predicate) {
|
|
402
402
|
case 'function': {
|
|
403
|
-
return zipWith.
|
|
403
|
+
return zipWith.dropWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
|
|
404
404
|
}
|
|
405
405
|
case 'object': {
|
|
406
406
|
if (Array.isArray(predicate) && predicate.length === 2) {
|
|
407
407
|
const key = predicate[0];
|
|
408
408
|
const value = predicate[1];
|
|
409
|
-
return zipWith.
|
|
409
|
+
return zipWith.dropWhile(arr, matchesProperty(key, value));
|
|
410
410
|
}
|
|
411
411
|
else {
|
|
412
|
-
return zipWith.
|
|
412
|
+
return zipWith.dropWhile(arr, matches(predicate));
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
case 'string': {
|
|
416
|
-
return zipWith.
|
|
416
|
+
return zipWith.dropWhile(arr, property(predicate));
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
@@ -436,11 +436,10 @@ function every(source, doesMatch) {
|
|
|
436
436
|
switch (typeof doesMatch) {
|
|
437
437
|
case 'function': {
|
|
438
438
|
if (!Array.isArray(source)) {
|
|
439
|
-
const
|
|
440
|
-
for (let i = 0; i <
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
const value = entry[1];
|
|
439
|
+
const keys = Object.keys(source);
|
|
440
|
+
for (let i = 0; i < keys.length; i++) {
|
|
441
|
+
const key = keys[i];
|
|
442
|
+
const value = source[key];
|
|
444
443
|
if (!doesMatch(value, key, source)) {
|
|
445
444
|
return false;
|
|
446
445
|
}
|
|
@@ -490,11 +489,10 @@ function filter(source, predicate) {
|
|
|
490
489
|
case 'function': {
|
|
491
490
|
if (!Array.isArray(source)) {
|
|
492
491
|
const result = [];
|
|
493
|
-
const
|
|
494
|
-
for (let i = 0; i <
|
|
495
|
-
const
|
|
496
|
-
const
|
|
497
|
-
const value = entry[1];
|
|
492
|
+
const keys = Object.keys(source);
|
|
493
|
+
for (let i = 0; i < keys.length; i++) {
|
|
494
|
+
const key = keys[i];
|
|
495
|
+
const value = source[key];
|
|
498
496
|
if (predicate(value, key, source)) {
|
|
499
497
|
result.push(value);
|
|
500
498
|
}
|
|
@@ -522,11 +520,10 @@ function find(source, doesMatch) {
|
|
|
522
520
|
switch (typeof doesMatch) {
|
|
523
521
|
case 'function': {
|
|
524
522
|
if (!Array.isArray(source)) {
|
|
525
|
-
const
|
|
526
|
-
for (let i = 0; i <
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
const value = entry[1];
|
|
523
|
+
const keys = Object.keys(source);
|
|
524
|
+
for (let i = 0; i < keys.length; i++) {
|
|
525
|
+
const key = keys[i];
|
|
526
|
+
const value = source[key];
|
|
530
527
|
if (doesMatch(value, key, source)) {
|
|
531
528
|
return value;
|
|
532
529
|
}
|
|
@@ -931,7 +928,7 @@ function ary(func, n = func.length, guard) {
|
|
|
931
928
|
if (Number.isNaN(n) || n < 0) {
|
|
932
929
|
n = 0;
|
|
933
930
|
}
|
|
934
|
-
return
|
|
931
|
+
return unary.ary(func, n);
|
|
935
932
|
}
|
|
936
933
|
|
|
937
934
|
function attempt(func, ...args) {
|
|
@@ -1145,7 +1142,7 @@ function debounce(func, debounceMs = 0, options = {}) {
|
|
|
1145
1142
|
}
|
|
1146
1143
|
let result = undefined;
|
|
1147
1144
|
let pendingAt = null;
|
|
1148
|
-
const _debounced =
|
|
1145
|
+
const _debounced = unary.debounce(function (...args) {
|
|
1149
1146
|
result = func.apply(this, args);
|
|
1150
1147
|
pendingAt = null;
|
|
1151
1148
|
}, debounceMs, { signal, edges });
|
|
@@ -1194,7 +1191,7 @@ function flow(...funcs) {
|
|
|
1194
1191
|
if (flattenFuncs.some(func => typeof func !== 'function')) {
|
|
1195
1192
|
throw new TypeError('Expected a function');
|
|
1196
1193
|
}
|
|
1197
|
-
return
|
|
1194
|
+
return unary.flow(...flattenFuncs);
|
|
1198
1195
|
}
|
|
1199
1196
|
|
|
1200
1197
|
function flowRight(...funcs) {
|
|
@@ -1202,7 +1199,7 @@ function flowRight(...funcs) {
|
|
|
1202
1199
|
if (flattenFuncs.some(func => typeof func !== 'function')) {
|
|
1203
1200
|
throw new TypeError('Expected a function');
|
|
1204
1201
|
}
|
|
1205
|
-
return
|
|
1202
|
+
return unary.flowRight(...flattenFuncs);
|
|
1206
1203
|
}
|
|
1207
1204
|
|
|
1208
1205
|
function rearg(func, ...indices) {
|
|
@@ -1221,7 +1218,7 @@ function rest(func, start = func.length - 1) {
|
|
|
1221
1218
|
if (Number.isNaN(start) || start < 0) {
|
|
1222
1219
|
start = func.length - 1;
|
|
1223
1220
|
}
|
|
1224
|
-
return
|
|
1221
|
+
return unary.rest(func, start);
|
|
1225
1222
|
}
|
|
1226
1223
|
|
|
1227
1224
|
function spread(func, argsIndex = 0) {
|
|
@@ -1786,13 +1783,13 @@ function isEqualWith(a, b, areValuesEqual = noop.noop) {
|
|
|
1786
1783
|
return isWeakSet$1.isEqualWith(a, b, (...args) => {
|
|
1787
1784
|
const result = areValuesEqual(...args);
|
|
1788
1785
|
if (result !== undefined) {
|
|
1789
|
-
return
|
|
1786
|
+
return Boolean(result);
|
|
1790
1787
|
}
|
|
1791
1788
|
if (a instanceof Map && b instanceof Map) {
|
|
1792
|
-
return isEqualWith(Array.from(a), Array.from(b),
|
|
1789
|
+
return isEqualWith(Array.from(a), Array.from(b), unary.after(2, areValuesEqual));
|
|
1793
1790
|
}
|
|
1794
1791
|
if (a instanceof Set && b instanceof Set) {
|
|
1795
|
-
return isEqualWith(Array.from(a), Array.from(b),
|
|
1792
|
+
return isEqualWith(Array.from(a), Array.from(b), unary.after(2, areValuesEqual));
|
|
1796
1793
|
}
|
|
1797
1794
|
});
|
|
1798
1795
|
}
|
|
@@ -1994,14 +1991,21 @@ function constant(value) {
|
|
|
1994
1991
|
return () => value;
|
|
1995
1992
|
}
|
|
1996
1993
|
|
|
1997
|
-
function
|
|
1994
|
+
function defaultTo(value, defaultValue) {
|
|
1995
|
+
if (value == null || Number.isNaN(value)) {
|
|
1996
|
+
return defaultValue;
|
|
1997
|
+
}
|
|
1998
|
+
return value;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
function times(n, getValue) {
|
|
1998
2002
|
n = toInteger(n);
|
|
1999
2003
|
if (n < 1 || !Number.isSafeInteger(n)) {
|
|
2000
2004
|
return [];
|
|
2001
2005
|
}
|
|
2002
2006
|
const result = new Array(n);
|
|
2003
2007
|
for (let i = 0; i < n; i++) {
|
|
2004
|
-
result[i] = typeof
|
|
2008
|
+
result[i] = typeof getValue === 'function' ? getValue(i) : i;
|
|
2005
2009
|
}
|
|
2006
2010
|
return result;
|
|
2007
2011
|
}
|
|
@@ -2016,13 +2020,6 @@ function toLength(value) {
|
|
|
2016
2020
|
return clamp(length, 0, MAX_ARRAY_LENGTH);
|
|
2017
2021
|
}
|
|
2018
2022
|
|
|
2019
|
-
function defaultTo(value, defaultValue) {
|
|
2020
|
-
if (value == null || Number.isNaN(value)) {
|
|
2021
|
-
return defaultValue;
|
|
2022
|
-
}
|
|
2023
|
-
return value;
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
2023
|
exports.at = zipWith.at;
|
|
2027
2024
|
exports.compact = zipWith.compact;
|
|
2028
2025
|
exports.countBy = zipWith.countBy;
|
|
@@ -2074,13 +2071,13 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
2074
2071
|
exports.delay = promise_index.delay;
|
|
2075
2072
|
exports.timeout = promise_index.timeout;
|
|
2076
2073
|
exports.withTimeout = promise_index.withTimeout;
|
|
2077
|
-
exports.after =
|
|
2078
|
-
exports.memoize =
|
|
2079
|
-
exports.negate =
|
|
2080
|
-
exports.once =
|
|
2081
|
-
exports.partial =
|
|
2082
|
-
exports.partialRight =
|
|
2083
|
-
exports.unary =
|
|
2074
|
+
exports.after = unary.after;
|
|
2075
|
+
exports.memoize = unary.memoize;
|
|
2076
|
+
exports.negate = unary.negate;
|
|
2077
|
+
exports.once = unary.once;
|
|
2078
|
+
exports.partial = unary.partial;
|
|
2079
|
+
exports.partialRight = unary.partialRight;
|
|
2080
|
+
exports.unary = unary.unary;
|
|
2084
2081
|
exports.noop = noop.noop;
|
|
2085
2082
|
exports.mean = sumBy.mean;
|
|
2086
2083
|
exports.meanBy = sumBy.meanBy;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -46,13 +46,13 @@ export { zipWith } from '../array/zipWith.mjs';
|
|
|
46
46
|
export { AbortError } from '../error/AbortError.mjs';
|
|
47
47
|
export { TimeoutError } from '../error/TimeoutError.mjs';
|
|
48
48
|
export { after } from '../function/after.mjs';
|
|
49
|
+
export { memoize } from '../function/memoize.mjs';
|
|
50
|
+
export { negate } from '../function/negate.mjs';
|
|
49
51
|
export { noop } from '../function/noop.mjs';
|
|
50
52
|
export { once } from '../function/once.mjs';
|
|
51
|
-
export { negate } from '../function/negate.mjs';
|
|
52
|
-
export { memoize } from '../function/memoize.mjs';
|
|
53
|
-
export { unary } from '../function/unary.mjs';
|
|
54
53
|
export { partial } from '../function/partial.mjs';
|
|
55
54
|
export { partialRight } from '../function/partialRight.mjs';
|
|
55
|
+
export { unary } from '../function/unary.mjs';
|
|
56
56
|
export { mean } from '../math/mean.mjs';
|
|
57
57
|
export { meanBy } from '../math/meanBy.mjs';
|
|
58
58
|
export { randomInt } from '../math/randomInt.mjs';
|
|
@@ -97,8 +97,8 @@ export { chunk } from './array/chunk.mjs';
|
|
|
97
97
|
export { concat } from './array/concat.mjs';
|
|
98
98
|
export { difference } from './array/difference.mjs';
|
|
99
99
|
export { drop } from './array/drop.mjs';
|
|
100
|
-
export { dropWhile } from './array/dropWhile.mjs';
|
|
101
100
|
export { dropRightWhile } from './array/dropRightWhile.mjs';
|
|
101
|
+
export { dropWhile } from './array/dropWhile.mjs';
|
|
102
102
|
export { every } from './array/every.mjs';
|
|
103
103
|
export { fill } from './array/fill.mjs';
|
|
104
104
|
export { filter } from './array/filter.mjs';
|
|
@@ -203,6 +203,7 @@ export { trim } from './string/trim.mjs';
|
|
|
203
203
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
204
204
|
export { trimStart } from './string/trimStart.mjs';
|
|
205
205
|
export { constant } from './util/constant.mjs';
|
|
206
|
+
export { defaultTo } from './util/defaultTo.mjs';
|
|
206
207
|
export { times } from './util/times.mjs';
|
|
207
208
|
export { toFinite } from './util/toFinite.mjs';
|
|
208
209
|
export { toInteger } from './util/toInteger.mjs';
|
|
@@ -210,4 +211,3 @@ export { toLength } from './util/toLength.mjs';
|
|
|
210
211
|
export { toNumber } from './util/toNumber.mjs';
|
|
211
212
|
export { toPath } from './util/toPath.mjs';
|
|
212
213
|
export { toString } from './util/toString.mjs';
|
|
213
|
-
export { defaultTo } from './util/defaultTo.mjs';
|
|
@@ -9,7 +9,7 @@ function isEqualWith(a, b, areValuesEqual = noop) {
|
|
|
9
9
|
return isEqualWith$1(a, b, (...args) => {
|
|
10
10
|
const result = areValuesEqual(...args);
|
|
11
11
|
if (result !== undefined) {
|
|
12
|
-
return
|
|
12
|
+
return Boolean(result);
|
|
13
13
|
}
|
|
14
14
|
if (a instanceof Map && b instanceof Map) {
|
|
15
15
|
return isEqualWith(Array.from(a), Array.from(b), after(2, areValuesEqual));
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Returns the default value for `null`, `undefined`, and `NaN`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param {unknown} defaultValue - The default value to return if the first value is null, undefined, or NaN.
|
|
8
|
-
* @returns {unknown} Returns either the first value or the default value.
|
|
4
|
+
* @param {T | null | undefined} value - The value to check.
|
|
5
|
+
* @param {T} [defaultValue] - The default value to return if the first value is null, undefined, or NaN.
|
|
6
|
+
* @returns {T} Returns either the first value or the default value.
|
|
9
7
|
*
|
|
10
8
|
* @example
|
|
11
9
|
* defaultTo(null, 'default') // returns 'default'
|
|
@@ -14,6 +12,6 @@
|
|
|
14
12
|
* defaultTo('actual', 'default') // returns 'actual'
|
|
15
13
|
* defaultTo(123, 0) // returns 123
|
|
16
14
|
*/
|
|
17
|
-
declare function defaultTo(value
|
|
15
|
+
declare function defaultTo<T>(value: T | null | undefined, defaultValue?: T): T;
|
|
18
16
|
|
|
19
17
|
export { defaultTo };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Returns the default value for `null`, `undefined`, and `NaN`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param {unknown} defaultValue - The default value to return if the first value is null, undefined, or NaN.
|
|
8
|
-
* @returns {unknown} Returns either the first value or the default value.
|
|
4
|
+
* @param {T | null | undefined} value - The value to check.
|
|
5
|
+
* @param {T} [defaultValue] - The default value to return if the first value is null, undefined, or NaN.
|
|
6
|
+
* @returns {T} Returns either the first value or the default value.
|
|
9
7
|
*
|
|
10
8
|
* @example
|
|
11
9
|
* defaultTo(null, 'default') // returns 'default'
|
|
@@ -14,6 +12,6 @@
|
|
|
14
12
|
* defaultTo('actual', 'default') // returns 'actual'
|
|
15
13
|
* defaultTo(123, 0) // returns 123
|
|
16
14
|
*/
|
|
17
|
-
declare function defaultTo(value
|
|
15
|
+
declare function defaultTo<T>(value: T | null | undefined, defaultValue?: T): T;
|
|
18
16
|
|
|
19
17
|
export { defaultTo };
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Invokes the
|
|
3
|
-
*
|
|
4
|
-
* The iteratee is invoked with one argument; (index).
|
|
5
|
-
*
|
|
6
|
-
* @template F The type of the iteratee function.
|
|
7
|
-
* @param {number} n - The number of times to invoke iteratee.
|
|
8
|
-
* @param {F extends (n: number) => any} [iteratee] - The function invoked per iteration. Default is identity.
|
|
9
|
-
* @returns {Array<ReturnType<F>>} - Returns the array of results.
|
|
2
|
+
* Invokes the getValue function n times, returning an array of the results.
|
|
10
3
|
*
|
|
4
|
+
* @template R The return type of the getValue function.
|
|
5
|
+
* @param {number} n - The number of times to invoke getValue.
|
|
6
|
+
* @param {(index: number) => R} getValue - The function to invoke for each index.
|
|
7
|
+
* @returns {R[]} An array containing the results of invoking getValue n times.
|
|
11
8
|
* @example
|
|
12
|
-
* times(3,
|
|
13
|
-
* times(
|
|
14
|
-
* times(2, () => 'es-toolkit') // => ['es-toolkit', 'es-toolkit']
|
|
9
|
+
* times(3, (i) => i * 2); // => [0, 2, 4]
|
|
10
|
+
* times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit']
|
|
15
11
|
*/
|
|
16
|
-
declare function times<
|
|
12
|
+
declare function times<R = number>(n?: number, getValue?: (index: number) => R): R[];
|
|
17
13
|
|
|
18
14
|
export { times };
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Invokes the
|
|
3
|
-
*
|
|
4
|
-
* The iteratee is invoked with one argument; (index).
|
|
5
|
-
*
|
|
6
|
-
* @template F The type of the iteratee function.
|
|
7
|
-
* @param {number} n - The number of times to invoke iteratee.
|
|
8
|
-
* @param {F extends (n: number) => any} [iteratee] - The function invoked per iteration. Default is identity.
|
|
9
|
-
* @returns {Array<ReturnType<F>>} - Returns the array of results.
|
|
2
|
+
* Invokes the getValue function n times, returning an array of the results.
|
|
10
3
|
*
|
|
4
|
+
* @template R The return type of the getValue function.
|
|
5
|
+
* @param {number} n - The number of times to invoke getValue.
|
|
6
|
+
* @param {(index: number) => R} getValue - The function to invoke for each index.
|
|
7
|
+
* @returns {R[]} An array containing the results of invoking getValue n times.
|
|
11
8
|
* @example
|
|
12
|
-
* times(3,
|
|
13
|
-
* times(
|
|
14
|
-
* times(2, () => 'es-toolkit') // => ['es-toolkit', 'es-toolkit']
|
|
9
|
+
* times(3, (i) => i * 2); // => [0, 2, 4]
|
|
10
|
+
* times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit']
|
|
15
11
|
*/
|
|
16
|
-
declare function times<
|
|
12
|
+
declare function times<R = number>(n?: number, getValue?: (index: number) => R): R[];
|
|
17
13
|
|
|
18
14
|
export { times };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { toInteger } from './toInteger.mjs';
|
|
2
2
|
|
|
3
|
-
function times(n,
|
|
3
|
+
function times(n, getValue) {
|
|
4
4
|
n = toInteger(n);
|
|
5
5
|
if (n < 1 || !Number.isSafeInteger(n)) {
|
|
6
6
|
return [];
|
|
7
7
|
}
|
|
8
8
|
const result = new Array(n);
|
|
9
9
|
for (let i = 0; i < n; i++) {
|
|
10
|
-
result[i] = typeof
|
|
10
|
+
result[i] = typeof getValue === 'function' ? getValue(i) : i;
|
|
11
11
|
}
|
|
12
12
|
return result;
|
|
13
13
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts value to an integer
|
|
2
|
+
* Converts the value to a valid index. A valid index is an integer that is greater than or equal to `0` and less than or equal to `2^32 - 1`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* It converts the given value to a number and floors it to an integer. If the value is less than `0`, it returns `0`. If the value exceeds `2^32 - 1`, it returns `2^32 - 1`.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} value - The value to convert to a valid index.
|
|
7
|
+
* @returns {number} The converted value.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* toLength(3.2) // => 3
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts value to an integer
|
|
2
|
+
* Converts the value to a valid index. A valid index is an integer that is greater than or equal to `0` and less than or equal to `2^32 - 1`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* It converts the given value to a number and floors it to an integer. If the value is less than `0`, it returns `0`. If the value exceeds `2^32 - 1`, it returns `2^32 - 1`.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} value - The value to convert to a valid index.
|
|
7
|
+
* @returns {number} The converted value.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* toLength(3.2) // => 3
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { before } from './before.mjs';
|
|
2
1
|
export { after } from './after.mjs';
|
|
2
|
+
export { ary } from './ary.mjs';
|
|
3
|
+
export { before } from './before.mjs';
|
|
4
|
+
export { curry } from './curry.mjs';
|
|
5
|
+
export { curryRight } from './curryRight.mjs';
|
|
3
6
|
export { debounce } from './debounce.mjs';
|
|
7
|
+
export { flow } from './flow.mjs';
|
|
8
|
+
export { flowRight } from './flowRight.mjs';
|
|
9
|
+
export { MemoizeCache, memoize } from './memoize.mjs';
|
|
10
|
+
export { negate } from './negate.mjs';
|
|
4
11
|
export { noop } from './noop.mjs';
|
|
5
12
|
export { once } from './once.mjs';
|
|
6
|
-
export { throttle } from './throttle.mjs';
|
|
7
|
-
export { negate } from './negate.mjs';
|
|
8
|
-
export { MemoizeCache, memoize } from './memoize.mjs';
|
|
9
|
-
export { ary } from './ary.mjs';
|
|
10
|
-
export { unary } from './unary.mjs';
|
|
11
13
|
export { partial } from './partial.mjs';
|
|
12
14
|
export { partialRight } from './partialRight.mjs';
|
|
13
15
|
export { rest } from './rest.mjs';
|
|
14
|
-
export { curry } from './curry.mjs';
|
|
15
|
-
export { curryRight } from './curryRight.mjs';
|
|
16
16
|
export { spread } from './spread.mjs';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
17
|
+
export { throttle } from './throttle.mjs';
|
|
18
|
+
export { unary } from './unary.mjs';
|
package/dist/function/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { before } from './before.js';
|
|
2
1
|
export { after } from './after.js';
|
|
2
|
+
export { ary } from './ary.js';
|
|
3
|
+
export { before } from './before.js';
|
|
4
|
+
export { curry } from './curry.js';
|
|
5
|
+
export { curryRight } from './curryRight.js';
|
|
3
6
|
export { debounce } from './debounce.js';
|
|
7
|
+
export { flow } from './flow.js';
|
|
8
|
+
export { flowRight } from './flowRight.js';
|
|
9
|
+
export { MemoizeCache, memoize } from './memoize.js';
|
|
10
|
+
export { negate } from './negate.js';
|
|
4
11
|
export { noop } from './noop.js';
|
|
5
12
|
export { once } from './once.js';
|
|
6
|
-
export { throttle } from './throttle.js';
|
|
7
|
-
export { negate } from './negate.js';
|
|
8
|
-
export { MemoizeCache, memoize } from './memoize.js';
|
|
9
|
-
export { ary } from './ary.js';
|
|
10
|
-
export { unary } from './unary.js';
|
|
11
13
|
export { partial } from './partial.js';
|
|
12
14
|
export { partialRight } from './partialRight.js';
|
|
13
15
|
export { rest } from './rest.js';
|
|
14
|
-
export { curry } from './curry.js';
|
|
15
|
-
export { curryRight } from './curryRight.js';
|
|
16
16
|
export { spread } from './spread.js';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
17
|
+
export { throttle } from './throttle.js';
|
|
18
|
+
export { unary } from './unary.js';
|