es-toolkit 1.35.0 → 1.36.0-dev.1215
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 +12 -0
- package/dist/_chunk/{isPromise-ByAybB.js → isPromise-CxqI1v.js} +122 -36
- package/dist/_chunk/{reverseString-D-wK2p.js → reverseString-BixeGz.js} +84 -13
- package/dist/_chunk/toSnakeCaseKeys-DZO2eB.js +4901 -0
- package/dist/_chunk/{unary-BsNWRM.js → unary-EIEhcF.js} +46 -0
- package/dist/_chunk/{zip-_HttSl.js → zip-BJSrRi.js} +38 -57
- package/dist/array/index.js +55 -6
- package/dist/array/pullAt.d.mts +0 -2
- package/dist/array/pullAt.d.ts +0 -2
- package/dist/array/take.d.mts +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.mjs +4 -1
- package/dist/array/takeRight.d.mts +1 -1
- package/dist/array/takeRight.d.ts +1 -1
- package/dist/array/takeRight.mjs +5 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/copyArray.mjs +12 -0
- package/dist/compat/_internal/mapToEntries.mjs +11 -0
- package/dist/compat/_internal/setToEntries.mjs +11 -0
- package/dist/compat/_internal/toKey.mjs +2 -2
- package/dist/compat/array/find.mjs +3 -3
- package/dist/compat/array/findLast.mjs +2 -2
- package/dist/compat/array/flatMap.d.mts +20 -0
- package/dist/compat/array/flatMap.d.ts +20 -0
- package/dist/compat/array/flatMap.mjs +13 -0
- package/dist/compat/array/forEachRight.d.mts +106 -0
- package/dist/compat/array/forEachRight.d.ts +106 -0
- package/dist/compat/array/forEachRight.mjs +21 -0
- package/dist/compat/array/groupBy.d.mts +55 -0
- package/dist/compat/array/groupBy.d.ts +55 -0
- package/dist/compat/array/groupBy.mjs +15 -0
- package/dist/compat/array/partition.d.mts +65 -0
- package/dist/compat/array/partition.d.ts +65 -0
- package/dist/compat/array/partition.mjs +24 -0
- package/dist/compat/array/pullAllWith.d.mts +59 -0
- package/dist/compat/array/pullAllWith.d.ts +59 -0
- package/dist/compat/array/pullAllWith.mjs +33 -0
- package/dist/compat/array/pullAt.d.mts +32 -0
- package/dist/compat/array/pullAt.d.ts +32 -0
- package/dist/compat/array/pullAt.mjs +34 -0
- package/dist/compat/compat.d.mts +310 -0
- package/dist/compat/compat.d.ts +310 -0
- package/dist/compat/compat.mjs +312 -0
- package/dist/compat/function/partial.d.mts +575 -0
- package/dist/compat/function/partial.d.ts +575 -0
- package/dist/compat/function/partial.mjs +8 -0
- package/dist/compat/function/partialRight.d.mts +651 -0
- package/dist/compat/function/partialRight.d.ts +651 -0
- package/dist/compat/function/partialRight.mjs +8 -0
- package/dist/compat/index.d.mts +16 -7
- package/dist/compat/index.d.ts +16 -7
- package/dist/compat/index.js +290 -3771
- package/dist/compat/index.mjs +19 -8
- package/dist/compat/object/defaults.mjs +7 -1
- package/dist/compat/object/forIn.d.mts +58 -0
- package/dist/compat/object/forIn.d.ts +58 -0
- package/dist/compat/object/forIn.mjs +16 -0
- package/dist/compat/object/forInRight.d.mts +58 -0
- package/dist/compat/object/forInRight.d.ts +58 -0
- package/dist/compat/object/forInRight.mjs +21 -0
- package/dist/compat/object/forOwn.d.mts +54 -0
- package/dist/compat/object/forOwn.d.ts +54 -0
- package/dist/compat/object/forOwn.mjs +19 -0
- package/dist/compat/object/forOwnRight.d.mts +54 -0
- package/dist/compat/object/forOwnRight.d.ts +54 -0
- package/dist/compat/object/forOwnRight.mjs +19 -0
- package/dist/compat/object/hasIn.d.mts +40 -0
- package/dist/compat/object/hasIn.d.ts +40 -0
- package/dist/compat/object/hasIn.mjs +34 -0
- package/dist/compat/object/toPairs.mjs +7 -2
- package/dist/compat/object/toPairsIn.mjs +7 -2
- package/dist/compat/string/repeat.d.mts +1 -1
- package/dist/compat/string/repeat.d.ts +1 -1
- package/dist/compat/string/repeat.mjs +12 -2
- package/dist/compat/string/words.d.mts +1 -1
- package/dist/compat/string/words.d.ts +1 -1
- package/dist/compat/string/words.mjs +2 -1
- package/dist/compat/toolkit.d.mts +9 -0
- package/dist/compat/toolkit.d.ts +9 -0
- package/dist/compat/toolkit.mjs +10 -0
- package/dist/compat/util/overEvery.d.mts +67 -0
- package/dist/compat/util/overEvery.d.ts +67 -0
- package/dist/compat/util/overEvery.mjs +23 -0
- package/dist/compat/util/overSome.d.mts +69 -0
- package/dist/compat/util/overSome.d.ts +69 -0
- package/dist/compat/util/overSome.mjs +23 -0
- package/dist/function/index.js +3 -5
- package/dist/function/partial.d.mts +3 -3
- package/dist/function/partial.d.ts +3 -3
- package/dist/function/partial.mjs +17 -19
- package/dist/function/partialRight.d.mts +3 -3
- package/dist/function/partialRight.d.ts +3 -3
- package/dist/function/partialRight.mjs +18 -20
- package/dist/function/throttle.mjs +0 -1
- package/dist/index.js +39 -42
- package/dist/object/index.js +15 -15
- package/dist/object/toCamelCaseKeys.mjs +3 -0
- package/dist/object/toSnakeCaseKeys.mjs +3 -0
- package/dist/predicate/index.js +4 -5
- package/dist/string/index.js +7 -8
- package/package.json +1 -1
- package/dist/_chunk/isPlainObject-Xaozpc.js +0 -93
- package/dist/_chunk/partialRight-B0_CSB.js +0 -50
- package/dist/_chunk/snakeCase-BtVEeB.js +0 -75
- package/dist/_chunk/toSnakeCaseKeys-BNpS71.js +0 -569
|
@@ -134,6 +134,48 @@ function once(func) {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
function partial(func, ...partialArgs) {
|
|
138
|
+
return partialImpl(func, placeholderSymbol$1, ...partialArgs);
|
|
139
|
+
}
|
|
140
|
+
function partialImpl(func, placeholder, ...partialArgs) {
|
|
141
|
+
const partialed = function (...providedArgs) {
|
|
142
|
+
let providedArgsIndex = 0;
|
|
143
|
+
const substitutedArgs = partialArgs
|
|
144
|
+
.slice()
|
|
145
|
+
.map(arg => (arg === placeholder ? providedArgs[providedArgsIndex++] : arg));
|
|
146
|
+
const remainingArgs = providedArgs.slice(providedArgsIndex);
|
|
147
|
+
return func.apply(this, substitutedArgs.concat(remainingArgs));
|
|
148
|
+
};
|
|
149
|
+
if (func.prototype) {
|
|
150
|
+
partialed.prototype = Object.create(func.prototype);
|
|
151
|
+
}
|
|
152
|
+
return partialed;
|
|
153
|
+
}
|
|
154
|
+
const placeholderSymbol$1 = Symbol('partial.placeholder');
|
|
155
|
+
partial.placeholder = placeholderSymbol$1;
|
|
156
|
+
|
|
157
|
+
function partialRight(func, ...partialArgs) {
|
|
158
|
+
return partialRightImpl(func, placeholderSymbol, ...partialArgs);
|
|
159
|
+
}
|
|
160
|
+
function partialRightImpl(func, placeholder, ...partialArgs) {
|
|
161
|
+
const partialedRight = function (...providedArgs) {
|
|
162
|
+
const placeholderLength = partialArgs.filter(arg => arg === placeholder).length;
|
|
163
|
+
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
164
|
+
const remainingArgs = providedArgs.slice(0, rangeLength);
|
|
165
|
+
let providedArgsIndex = rangeLength;
|
|
166
|
+
const substitutedArgs = partialArgs
|
|
167
|
+
.slice()
|
|
168
|
+
.map(arg => (arg === placeholder ? providedArgs[providedArgsIndex++] : arg));
|
|
169
|
+
return func.apply(this, remainingArgs.concat(substitutedArgs));
|
|
170
|
+
};
|
|
171
|
+
if (func.prototype) {
|
|
172
|
+
partialedRight.prototype = Object.create(func.prototype);
|
|
173
|
+
}
|
|
174
|
+
return partialedRight;
|
|
175
|
+
}
|
|
176
|
+
const placeholderSymbol = Symbol('partialRight.placeholder');
|
|
177
|
+
partialRight.placeholder = placeholderSymbol;
|
|
178
|
+
|
|
137
179
|
function rest(func, startIndex = func.length - 1) {
|
|
138
180
|
return function (...args) {
|
|
139
181
|
const rest = args.slice(startIndex);
|
|
@@ -192,6 +234,10 @@ exports.identity = identity;
|
|
|
192
234
|
exports.memoize = memoize;
|
|
193
235
|
exports.negate = negate;
|
|
194
236
|
exports.once = once;
|
|
237
|
+
exports.partial = partial;
|
|
238
|
+
exports.partialImpl = partialImpl;
|
|
239
|
+
exports.partialRight = partialRight;
|
|
240
|
+
exports.partialRightImpl = partialRightImpl;
|
|
195
241
|
exports.rest = rest;
|
|
196
242
|
exports.retry = retry;
|
|
197
243
|
exports.unary = unary;
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const randomInt = require('./randomInt-CF7bZK.js');
|
|
4
4
|
|
|
5
|
-
function at(arr, indices) {
|
|
6
|
-
const result = new Array(indices.length);
|
|
7
|
-
const length = arr.length;
|
|
8
|
-
for (let i = 0; i < indices.length; i++) {
|
|
9
|
-
let index = indices[i];
|
|
10
|
-
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
|
|
11
|
-
if (index < 0) {
|
|
12
|
-
index += length;
|
|
13
|
-
}
|
|
14
|
-
result[i] = arr[index];
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
function chunk(arr, size) {
|
|
20
6
|
if (!Number.isInteger(size) || size <= 0) {
|
|
21
7
|
throw new Error('Size must be an integer greater than zero.');
|
|
@@ -129,10 +115,6 @@ function flatten(arr, depth = 1) {
|
|
|
129
115
|
return result;
|
|
130
116
|
}
|
|
131
117
|
|
|
132
|
-
function flatMap(arr, iteratee, depth = 1) {
|
|
133
|
-
return flatten(arr.map(item => iteratee(item)), depth);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
118
|
function flattenDeep(arr) {
|
|
137
119
|
return flatten(arr, Infinity);
|
|
138
120
|
}
|
|
@@ -141,13 +123,6 @@ function flatMapDeep(arr, iteratee) {
|
|
|
141
123
|
return flattenDeep(arr.map((item) => iteratee(item)));
|
|
142
124
|
}
|
|
143
125
|
|
|
144
|
-
function forEachRight(arr, callback) {
|
|
145
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
146
|
-
const element = arr[i];
|
|
147
|
-
callback(element, i, arr);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
126
|
function groupBy(arr, getKeyFromItem) {
|
|
152
127
|
const result = {};
|
|
153
128
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -239,21 +214,6 @@ function minBy(items, getValue) {
|
|
|
239
214
|
return minElement;
|
|
240
215
|
}
|
|
241
216
|
|
|
242
|
-
function partition(arr, isInTruthy) {
|
|
243
|
-
const truthy = [];
|
|
244
|
-
const falsy = [];
|
|
245
|
-
for (let i = 0; i < arr.length; i++) {
|
|
246
|
-
const item = arr[i];
|
|
247
|
-
if (isInTruthy(item)) {
|
|
248
|
-
truthy.push(item);
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
falsy.push(item);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return [truthy, falsy];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
217
|
function pull(arr, valuesToRemove) {
|
|
258
218
|
const valuesSet = new Set(valuesToRemove);
|
|
259
219
|
let resultIndex = 0;
|
|
@@ -271,15 +231,6 @@ function pull(arr, valuesToRemove) {
|
|
|
271
231
|
return arr;
|
|
272
232
|
}
|
|
273
233
|
|
|
274
|
-
function pullAt(arr, indicesToRemove) {
|
|
275
|
-
const removed = at(arr, indicesToRemove);
|
|
276
|
-
const indices = new Set(indicesToRemove.slice().sort((x, y) => y - x));
|
|
277
|
-
for (const index of indices) {
|
|
278
|
-
arr.splice(index, 1);
|
|
279
|
-
}
|
|
280
|
-
return removed;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
234
|
function remove(arr, shouldRemoveElement) {
|
|
284
235
|
const originalArr = arr.slice();
|
|
285
236
|
const removed = [];
|
|
@@ -334,12 +285,43 @@ function tail(arr) {
|
|
|
334
285
|
return arr.slice(1);
|
|
335
286
|
}
|
|
336
287
|
|
|
337
|
-
function
|
|
288
|
+
function isSymbol(value) {
|
|
289
|
+
return typeof value === 'symbol' || value instanceof Symbol;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function toNumber(value) {
|
|
293
|
+
if (isSymbol(value)) {
|
|
294
|
+
return NaN;
|
|
295
|
+
}
|
|
296
|
+
return Number(value);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function toFinite(value) {
|
|
300
|
+
if (!value) {
|
|
301
|
+
return value === 0 ? value : 0;
|
|
302
|
+
}
|
|
303
|
+
value = toNumber(value);
|
|
304
|
+
if (value === Infinity || value === -Infinity) {
|
|
305
|
+
const sign = value < 0 ? -1 : 1;
|
|
306
|
+
return sign * Number.MAX_VALUE;
|
|
307
|
+
}
|
|
308
|
+
return value === value ? value : 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function toInteger(value) {
|
|
312
|
+
const finite = toFinite(value);
|
|
313
|
+
const remainder = finite % 1;
|
|
314
|
+
return remainder ? finite - remainder : finite;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function take(arr, count, guard) {
|
|
318
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
338
319
|
return arr.slice(0, count);
|
|
339
320
|
}
|
|
340
321
|
|
|
341
|
-
function takeRight(arr, count = 1) {
|
|
342
|
-
|
|
322
|
+
function takeRight(arr, count = 1, guard) {
|
|
323
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
324
|
+
if (count <= 0 || arr == null || arr.length === 0) {
|
|
343
325
|
return [];
|
|
344
326
|
}
|
|
345
327
|
return arr.slice(-count);
|
|
@@ -480,7 +462,6 @@ function zip(...arrs) {
|
|
|
480
462
|
return result;
|
|
481
463
|
}
|
|
482
464
|
|
|
483
|
-
exports.at = at;
|
|
484
465
|
exports.chunk = chunk;
|
|
485
466
|
exports.compact = compact;
|
|
486
467
|
exports.countBy = countBy;
|
|
@@ -492,11 +473,9 @@ exports.dropRight = dropRight;
|
|
|
492
473
|
exports.dropRightWhile = dropRightWhile;
|
|
493
474
|
exports.dropWhile = dropWhile;
|
|
494
475
|
exports.fill = fill;
|
|
495
|
-
exports.flatMap = flatMap;
|
|
496
476
|
exports.flatMapDeep = flatMapDeep;
|
|
497
477
|
exports.flatten = flatten;
|
|
498
478
|
exports.flattenDeep = flattenDeep;
|
|
499
|
-
exports.forEachRight = forEachRight;
|
|
500
479
|
exports.groupBy = groupBy;
|
|
501
480
|
exports.head = head;
|
|
502
481
|
exports.initial = initial;
|
|
@@ -505,13 +484,12 @@ exports.intersectionBy = intersectionBy;
|
|
|
505
484
|
exports.intersectionWith = intersectionWith;
|
|
506
485
|
exports.isSubset = isSubset;
|
|
507
486
|
exports.isSubsetWith = isSubsetWith;
|
|
487
|
+
exports.isSymbol = isSymbol;
|
|
508
488
|
exports.keyBy = keyBy;
|
|
509
489
|
exports.last = last;
|
|
510
490
|
exports.maxBy = maxBy;
|
|
511
491
|
exports.minBy = minBy;
|
|
512
|
-
exports.partition = partition;
|
|
513
492
|
exports.pull = pull;
|
|
514
|
-
exports.pullAt = pullAt;
|
|
515
493
|
exports.remove = remove;
|
|
516
494
|
exports.sample = sample;
|
|
517
495
|
exports.sampleSize = sampleSize;
|
|
@@ -520,6 +498,9 @@ exports.tail = tail;
|
|
|
520
498
|
exports.take = take;
|
|
521
499
|
exports.takeRight = takeRight;
|
|
522
500
|
exports.toFilled = toFilled;
|
|
501
|
+
exports.toFinite = toFinite;
|
|
502
|
+
exports.toInteger = toInteger;
|
|
503
|
+
exports.toNumber = toNumber;
|
|
523
504
|
exports.union = union;
|
|
524
505
|
exports.unionBy = unionBy;
|
|
525
506
|
exports.unionWith = unionWith;
|
package/dist/array/index.js
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zip = require('../_chunk/zip-
|
|
5
|
+
const zip = require('../_chunk/zip-BJSrRi.js');
|
|
6
|
+
|
|
7
|
+
function at(arr, indices) {
|
|
8
|
+
const result = new Array(indices.length);
|
|
9
|
+
const length = arr.length;
|
|
10
|
+
for (let i = 0; i < indices.length; i++) {
|
|
11
|
+
let index = indices[i];
|
|
12
|
+
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
|
|
13
|
+
if (index < 0) {
|
|
14
|
+
index += length;
|
|
15
|
+
}
|
|
16
|
+
result[i] = arr[index];
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
22
|
+
return zip.flatten(arr.map(item => iteratee(item)), depth);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function forEachRight(arr, callback) {
|
|
26
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
27
|
+
const element = arr[i];
|
|
28
|
+
callback(element, i, arr);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
6
31
|
|
|
7
32
|
function compareValues(a, b, order) {
|
|
8
33
|
if (a < b) {
|
|
@@ -32,6 +57,30 @@ function orderBy(arr, criteria, orders) {
|
|
|
32
57
|
});
|
|
33
58
|
}
|
|
34
59
|
|
|
60
|
+
function partition(arr, isInTruthy) {
|
|
61
|
+
const truthy = [];
|
|
62
|
+
const falsy = [];
|
|
63
|
+
for (let i = 0; i < arr.length; i++) {
|
|
64
|
+
const item = arr[i];
|
|
65
|
+
if (isInTruthy(item)) {
|
|
66
|
+
truthy.push(item);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
falsy.push(item);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [truthy, falsy];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function pullAt(arr, indicesToRemove) {
|
|
76
|
+
const removed = at(arr, indicesToRemove);
|
|
77
|
+
const indices = new Set(indicesToRemove.slice().sort((x, y) => y - x));
|
|
78
|
+
for (const index of indices) {
|
|
79
|
+
arr.splice(index, 1);
|
|
80
|
+
}
|
|
81
|
+
return removed;
|
|
82
|
+
}
|
|
83
|
+
|
|
35
84
|
function sortBy(arr, criteria) {
|
|
36
85
|
return orderBy(arr, criteria, ['asc']);
|
|
37
86
|
}
|
|
@@ -77,7 +126,6 @@ function zipWith(arr1, ...rest) {
|
|
|
77
126
|
return result;
|
|
78
127
|
}
|
|
79
128
|
|
|
80
|
-
exports.at = zip.at;
|
|
81
129
|
exports.chunk = zip.chunk;
|
|
82
130
|
exports.compact = zip.compact;
|
|
83
131
|
exports.countBy = zip.countBy;
|
|
@@ -89,11 +137,9 @@ exports.dropRight = zip.dropRight;
|
|
|
89
137
|
exports.dropRightWhile = zip.dropRightWhile;
|
|
90
138
|
exports.dropWhile = zip.dropWhile;
|
|
91
139
|
exports.fill = zip.fill;
|
|
92
|
-
exports.flatMap = zip.flatMap;
|
|
93
140
|
exports.flatMapDeep = zip.flatMapDeep;
|
|
94
141
|
exports.flatten = zip.flatten;
|
|
95
142
|
exports.flattenDeep = zip.flattenDeep;
|
|
96
|
-
exports.forEachRight = zip.forEachRight;
|
|
97
143
|
exports.groupBy = zip.groupBy;
|
|
98
144
|
exports.head = zip.head;
|
|
99
145
|
exports.initial = zip.initial;
|
|
@@ -106,9 +152,7 @@ exports.keyBy = zip.keyBy;
|
|
|
106
152
|
exports.last = zip.last;
|
|
107
153
|
exports.maxBy = zip.maxBy;
|
|
108
154
|
exports.minBy = zip.minBy;
|
|
109
|
-
exports.partition = zip.partition;
|
|
110
155
|
exports.pull = zip.pull;
|
|
111
|
-
exports.pullAt = zip.pullAt;
|
|
112
156
|
exports.remove = zip.remove;
|
|
113
157
|
exports.sample = zip.sample;
|
|
114
158
|
exports.sampleSize = zip.sampleSize;
|
|
@@ -131,7 +175,12 @@ exports.xor = zip.xor;
|
|
|
131
175
|
exports.xorBy = zip.xorBy;
|
|
132
176
|
exports.xorWith = zip.xorWith;
|
|
133
177
|
exports.zip = zip.zip;
|
|
178
|
+
exports.at = at;
|
|
179
|
+
exports.flatMap = flatMap;
|
|
180
|
+
exports.forEachRight = forEachRight;
|
|
134
181
|
exports.orderBy = orderBy;
|
|
182
|
+
exports.partition = partition;
|
|
183
|
+
exports.pullAt = pullAt;
|
|
135
184
|
exports.sortBy = sortBy;
|
|
136
185
|
exports.takeRightWhile = takeRightWhile;
|
|
137
186
|
exports.takeWhile = takeWhile;
|
package/dist/array/pullAt.d.mts
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* @returns {Array<T | undefined>} An array containing the elements that were removed from the original array.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* import { pullAt } from './pullAt';
|
|
13
|
-
*
|
|
14
12
|
* const numbers = [10, 20, 30, 40, 50];
|
|
15
13
|
* const removed = pullAt(numbers, [1, 3, 4]);
|
|
16
14
|
* console.log(removed); // [20, 40, 50]
|
package/dist/array/pullAt.d.ts
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* @returns {Array<T | undefined>} An array containing the elements that were removed from the original array.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* import { pullAt } from './pullAt';
|
|
13
|
-
*
|
|
14
12
|
* const numbers = [10, 20, 30, 40, 50];
|
|
15
13
|
* const removed = pullAt(numbers, [1, 3, 4]);
|
|
16
14
|
* console.log(removed); // [20, 40, 50]
|
package/dist/array/take.d.mts
CHANGED
package/dist/array/take.d.ts
CHANGED
package/dist/array/take.mjs
CHANGED
package/dist/array/takeRight.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { toInteger } from '../compat/util/toInteger.mjs';
|
|
2
|
+
|
|
3
|
+
function takeRight(arr, count = 1, guard) {
|
|
4
|
+
count = guard || count === undefined ? 1 : toInteger(count);
|
|
5
|
+
if (count <= 0 || arr == null || arr.length === 0) {
|
|
3
6
|
return [];
|
|
4
7
|
}
|
|
5
8
|
return arr.slice(-count);
|