es-toolkit 1.29.0-dev.944 → 1.29.0-dev.945
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/{zipWith-DLxOmJ.js → zipWith-nbzldx.js} +0 -10
- package/dist/array/index.js +11 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/takeRightWhile.d.mts +84 -0
- package/dist/compat/array/takeRightWhile.d.ts +84 -0
- package/dist/compat/array/takeRightWhile.mjs +15 -0
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +11 -2
- package/dist/compat/index.mjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a slice of array.
|
|
3
|
+
*
|
|
4
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
5
|
+
*
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
8
|
+
* @returns {T[]} - A slice of the array or an empty array if `array` is `null` or `undefined`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const items = [1, 2, 3];
|
|
12
|
+
* const result = takeRightWhile(items);
|
|
13
|
+
* console.log(result); // [1, 2, 3]
|
|
14
|
+
*
|
|
15
|
+
* const result2 = takeRightWhile(null);
|
|
16
|
+
* console.log(result2); // []
|
|
17
|
+
*/
|
|
18
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined): T[];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a slice of array with elements taken from the end until the predicate function returns falsey.
|
|
21
|
+
*
|
|
22
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
23
|
+
*
|
|
24
|
+
* @template T
|
|
25
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
26
|
+
* @param {(item: T, index: number, array: T[]) => unknown} predicate - A function invoked per iteration. Returns a truthy value to continue taking elements.
|
|
27
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const items = [1, 2, 3, 4, 5];
|
|
31
|
+
* const result = takeRightWhile(items, (item) => item > 3);
|
|
32
|
+
* console.log(result); // [4, 5]
|
|
33
|
+
*/
|
|
34
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, predicate: (item: T, index: number, array: T[]) => unknown): T[];
|
|
35
|
+
/**
|
|
36
|
+
* Creates a slice of array with elements taken from the end until the element does not match the given object.
|
|
37
|
+
*
|
|
38
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
39
|
+
*
|
|
40
|
+
* @template T
|
|
41
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
42
|
+
* @param {Partial<T>} matches - A partial object that specifies the properties to match.
|
|
43
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const items = [{ id: 10 }, { id: 20 }, { id: 30 }];
|
|
47
|
+
* const result = takeRightWhile(items, { id: 30 });
|
|
48
|
+
* console.log(result); // [{ id: 30 }]
|
|
49
|
+
*/
|
|
50
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, matches: Partial<T>): T[];
|
|
51
|
+
/**
|
|
52
|
+
* Creates a slice of array with elements taken from the end until the element does not match the given property key and value.
|
|
53
|
+
*
|
|
54
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
55
|
+
*
|
|
56
|
+
* @template T
|
|
57
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
58
|
+
* @param {[keyof T, unknown]} matchesProperty - An array where the first element is the property key and the second element is the value to match.
|
|
59
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const items = [{ name: 'Alice' }, { name: 'Bob' }, { name: 'Alice' }];
|
|
63
|
+
* const result = takeRightWhile(items, ['name', 'Alice']);
|
|
64
|
+
* console.log(result); // [{ name: 'Alice' }]
|
|
65
|
+
*/
|
|
66
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, matchesProperty: [keyof T, unknown]): T[];
|
|
67
|
+
/**
|
|
68
|
+
* Creates a slice of array with elements taken from the end until the element does not have a truthy value for the given property key.
|
|
69
|
+
*
|
|
70
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
71
|
+
*
|
|
72
|
+
* @template T
|
|
73
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
74
|
+
* @param {PropertyKey} property - A property key. Elements are included if they have a truthy value for this key.
|
|
75
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const items = [{ valid: false }, { valid: true }, { valid: true }];
|
|
79
|
+
* const result = takeRightWhile(items, 'valid');
|
|
80
|
+
* console.log(result); // [{ valid: true }, { valid: true }]
|
|
81
|
+
*/
|
|
82
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, property: PropertyKey): T[];
|
|
83
|
+
|
|
84
|
+
export { takeRightWhile };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a slice of array.
|
|
3
|
+
*
|
|
4
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
5
|
+
*
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
8
|
+
* @returns {T[]} - A slice of the array or an empty array if `array` is `null` or `undefined`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const items = [1, 2, 3];
|
|
12
|
+
* const result = takeRightWhile(items);
|
|
13
|
+
* console.log(result); // [1, 2, 3]
|
|
14
|
+
*
|
|
15
|
+
* const result2 = takeRightWhile(null);
|
|
16
|
+
* console.log(result2); // []
|
|
17
|
+
*/
|
|
18
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined): T[];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a slice of array with elements taken from the end until the predicate function returns falsey.
|
|
21
|
+
*
|
|
22
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
23
|
+
*
|
|
24
|
+
* @template T
|
|
25
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
26
|
+
* @param {(item: T, index: number, array: T[]) => unknown} predicate - A function invoked per iteration. Returns a truthy value to continue taking elements.
|
|
27
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const items = [1, 2, 3, 4, 5];
|
|
31
|
+
* const result = takeRightWhile(items, (item) => item > 3);
|
|
32
|
+
* console.log(result); // [4, 5]
|
|
33
|
+
*/
|
|
34
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, predicate: (item: T, index: number, array: T[]) => unknown): T[];
|
|
35
|
+
/**
|
|
36
|
+
* Creates a slice of array with elements taken from the end until the element does not match the given object.
|
|
37
|
+
*
|
|
38
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
39
|
+
*
|
|
40
|
+
* @template T
|
|
41
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
42
|
+
* @param {Partial<T>} matches - A partial object that specifies the properties to match.
|
|
43
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const items = [{ id: 10 }, { id: 20 }, { id: 30 }];
|
|
47
|
+
* const result = takeRightWhile(items, { id: 30 });
|
|
48
|
+
* console.log(result); // [{ id: 30 }]
|
|
49
|
+
*/
|
|
50
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, matches: Partial<T>): T[];
|
|
51
|
+
/**
|
|
52
|
+
* Creates a slice of array with elements taken from the end until the element does not match the given property key and value.
|
|
53
|
+
*
|
|
54
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
55
|
+
*
|
|
56
|
+
* @template T
|
|
57
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
58
|
+
* @param {[keyof T, unknown]} matchesProperty - An array where the first element is the property key and the second element is the value to match.
|
|
59
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const items = [{ name: 'Alice' }, { name: 'Bob' }, { name: 'Alice' }];
|
|
63
|
+
* const result = takeRightWhile(items, ['name', 'Alice']);
|
|
64
|
+
* console.log(result); // [{ name: 'Alice' }]
|
|
65
|
+
*/
|
|
66
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, matchesProperty: [keyof T, unknown]): T[];
|
|
67
|
+
/**
|
|
68
|
+
* Creates a slice of array with elements taken from the end until the element does not have a truthy value for the given property key.
|
|
69
|
+
*
|
|
70
|
+
* If the array is `null` or `undefined`, returns an empty array.
|
|
71
|
+
*
|
|
72
|
+
* @template T
|
|
73
|
+
* @param {ArrayLike<T> | null | undefined} array - The array to process.
|
|
74
|
+
* @param {PropertyKey} property - A property key. Elements are included if they have a truthy value for this key.
|
|
75
|
+
* @returns {T[]} - A slice of the array with elements taken from the end or an empty array if `array` is `null` or `undefined`.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const items = [{ valid: false }, { valid: true }, { valid: true }];
|
|
79
|
+
* const result = takeRightWhile(items, 'valid');
|
|
80
|
+
* console.log(result); // [{ valid: true }, { valid: true }]
|
|
81
|
+
*/
|
|
82
|
+
declare function takeRightWhile<T>(array: ArrayLike<T> | null | undefined, property: PropertyKey): T[];
|
|
83
|
+
|
|
84
|
+
export { takeRightWhile };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { negate } from '../../function/negate.mjs';
|
|
2
|
+
import { toArray } from '../_internal/toArray.mjs';
|
|
3
|
+
import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|
4
|
+
import { iteratee } from '../util/iteratee.mjs';
|
|
5
|
+
|
|
6
|
+
function takeRightWhile(_array, predicate) {
|
|
7
|
+
if (!isArrayLikeObject(_array)) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
const array = toArray(_array);
|
|
11
|
+
const index = array.findLastIndex(negate(iteratee(predicate)));
|
|
12
|
+
return array.slice(index + 1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { takeRightWhile };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@ export { partition } from '../array/partition.mjs';
|
|
|
15
15
|
export { pullAt } from '../array/pullAt.mjs';
|
|
16
16
|
export { sampleSize } from '../array/sampleSize.mjs';
|
|
17
17
|
export { shuffle } from '../array/shuffle.mjs';
|
|
18
|
-
export { takeRightWhile } from '../array/takeRightWhile.mjs';
|
|
19
18
|
export { takeWhile } from '../array/takeWhile.mjs';
|
|
20
19
|
export { toFilled } from '../array/toFilled.mjs';
|
|
21
20
|
export { unionBy } from '../array/unionBy.mjs';
|
|
@@ -111,6 +110,7 @@ export { sortBy } from './array/sortBy.mjs';
|
|
|
111
110
|
export { tail } from './array/tail.mjs';
|
|
112
111
|
export { take } from './array/take.mjs';
|
|
113
112
|
export { takeRight } from './array/takeRight.mjs';
|
|
113
|
+
export { takeRightWhile } from './array/takeRightWhile.mjs';
|
|
114
114
|
export { union } from './array/union.mjs';
|
|
115
115
|
export { uniq } from './array/uniq.mjs';
|
|
116
116
|
export { uniqBy } from './array/uniqBy.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { partition } from '../array/partition.js';
|
|
|
15
15
|
export { pullAt } from '../array/pullAt.js';
|
|
16
16
|
export { sampleSize } from '../array/sampleSize.js';
|
|
17
17
|
export { shuffle } from '../array/shuffle.js';
|
|
18
|
-
export { takeRightWhile } from '../array/takeRightWhile.js';
|
|
19
18
|
export { takeWhile } from '../array/takeWhile.js';
|
|
20
19
|
export { toFilled } from '../array/toFilled.js';
|
|
21
20
|
export { unionBy } from '../array/unionBy.js';
|
|
@@ -111,6 +110,7 @@ export { sortBy } from './array/sortBy.js';
|
|
|
111
110
|
export { tail } from './array/tail.js';
|
|
112
111
|
export { take } from './array/take.js';
|
|
113
112
|
export { takeRight } from './array/takeRight.js';
|
|
113
|
+
export { takeRightWhile } from './array/takeRightWhile.js';
|
|
114
114
|
export { union } from './array/union.js';
|
|
115
115
|
export { uniq } from './array/uniq.js';
|
|
116
116
|
export { uniqBy } from './array/uniqBy.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('../_chunk/zipWith-
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-nbzldx.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
7
|
const unary = require('../_chunk/unary-CcTNuC.js');
|
|
8
8
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
@@ -1303,6 +1303,15 @@ function takeRight(arr, count = 1, guard) {
|
|
|
1303
1303
|
return zipWith.takeRight(toArray$1(arr), count);
|
|
1304
1304
|
}
|
|
1305
1305
|
|
|
1306
|
+
function takeRightWhile(_array, predicate) {
|
|
1307
|
+
if (!isArrayLikeObject(_array)) {
|
|
1308
|
+
return [];
|
|
1309
|
+
}
|
|
1310
|
+
const array = toArray$1(_array);
|
|
1311
|
+
const index = array.findLastIndex(unary.negate(iteratee(predicate)));
|
|
1312
|
+
return array.slice(index + 1);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1306
1315
|
function union(...arrays) {
|
|
1307
1316
|
const validArrays = arrays.filter(isArrayLikeObject);
|
|
1308
1317
|
const flattened = flatten(validArrays, 1);
|
|
@@ -2920,7 +2929,6 @@ exports.partition = zipWith.partition;
|
|
|
2920
2929
|
exports.pullAt = zipWith.pullAt;
|
|
2921
2930
|
exports.sampleSize = zipWith.sampleSize;
|
|
2922
2931
|
exports.shuffle = zipWith.shuffle;
|
|
2923
|
-
exports.takeRightWhile = zipWith.takeRightWhile;
|
|
2924
2932
|
exports.takeWhile = zipWith.takeWhile;
|
|
2925
2933
|
exports.toFilled = zipWith.toFilled;
|
|
2926
2934
|
exports.unionBy = zipWith.unionBy;
|
|
@@ -3131,6 +3139,7 @@ exports.sumBy = sumBy;
|
|
|
3131
3139
|
exports.tail = tail;
|
|
3132
3140
|
exports.take = take;
|
|
3133
3141
|
exports.takeRight = takeRight;
|
|
3142
|
+
exports.takeRightWhile = takeRightWhile;
|
|
3134
3143
|
exports.template = template;
|
|
3135
3144
|
exports.templateSettings = templateSettings;
|
|
3136
3145
|
exports.throttle = throttle;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -15,7 +15,6 @@ export { partition } from '../array/partition.mjs';
|
|
|
15
15
|
export { pullAt } from '../array/pullAt.mjs';
|
|
16
16
|
export { sampleSize } from '../array/sampleSize.mjs';
|
|
17
17
|
export { shuffle } from '../array/shuffle.mjs';
|
|
18
|
-
export { takeRightWhile } from '../array/takeRightWhile.mjs';
|
|
19
18
|
export { takeWhile } from '../array/takeWhile.mjs';
|
|
20
19
|
export { toFilled } from '../array/toFilled.mjs';
|
|
21
20
|
export { unionBy } from '../array/unionBy.mjs';
|
|
@@ -113,6 +112,7 @@ export { sortBy } from './array/sortBy.mjs';
|
|
|
113
112
|
export { tail } from './array/tail.mjs';
|
|
114
113
|
export { take } from './array/take.mjs';
|
|
115
114
|
export { takeRight } from './array/takeRight.mjs';
|
|
115
|
+
export { takeRightWhile } from './array/takeRightWhile.mjs';
|
|
116
116
|
export { union } from './array/union.mjs';
|
|
117
117
|
export { uniq } from './array/uniq.mjs';
|
|
118
118
|
export { uniqBy } from './array/uniqBy.mjs';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('./_chunk/zipWith-
|
|
5
|
+
const zipWith = require('./_chunk/zipWith-nbzldx.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
7
|
const promise_index = require('./_chunk/index-BGZDR9.js');
|
|
8
8
|
const unary = require('./_chunk/unary-CcTNuC.js');
|
|
@@ -60,7 +60,6 @@ exports.shuffle = zipWith.shuffle;
|
|
|
60
60
|
exports.tail = zipWith.tail;
|
|
61
61
|
exports.take = zipWith.take;
|
|
62
62
|
exports.takeRight = zipWith.takeRight;
|
|
63
|
-
exports.takeRightWhile = zipWith.takeRightWhile;
|
|
64
63
|
exports.takeWhile = zipWith.takeWhile;
|
|
65
64
|
exports.toFilled = zipWith.toFilled;
|
|
66
65
|
exports.union = zipWith.union;
|
|
@@ -80,6 +79,7 @@ exports.zipObject = zipWith.zipObject;
|
|
|
80
79
|
exports.zipWith = zipWith.zipWith;
|
|
81
80
|
exports.orderBy = array_index.orderBy;
|
|
82
81
|
exports.sortBy = array_index.sortBy;
|
|
82
|
+
exports.takeRightWhile = array_index.takeRightWhile;
|
|
83
83
|
exports.AbortError = promise_index.AbortError;
|
|
84
84
|
exports.TimeoutError = promise_index.TimeoutError;
|
|
85
85
|
exports.delay = promise_index.delay;
|
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.29.0-dev.
|
|
4
|
+
"version": "1.29.0-dev.945+69c42745",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|