es-toolkit 1.48.1-dev.1881 → 1.48.1-dev.1883
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.
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* of elements removed from the start.
|
|
7
7
|
*
|
|
8
8
|
* @template T - The type of elements in the array.
|
|
9
|
-
* @param
|
|
9
|
+
* @param array - The array from which to drop elements.
|
|
10
10
|
* @param itemsCount - The number of elements to drop from the beginning of the array.
|
|
11
|
-
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
|
|
12
11
|
* @returns A new array with the specified number of elements removed from the start.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
@@ -16,6 +15,6 @@
|
|
|
16
15
|
* const result = drop(array, 2);
|
|
17
16
|
* result will be [3, 4, 5] since the first two elements are dropped.
|
|
18
17
|
*/
|
|
19
|
-
declare function drop<T>(array: ArrayLike<T> | null | undefined,
|
|
18
|
+
declare function drop<T>(array: ArrayLike<T> | null | undefined, itemsCount?: number): T[];
|
|
20
19
|
//#endregion
|
|
21
20
|
export { drop };
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* of elements removed from the start.
|
|
7
7
|
*
|
|
8
8
|
* @template T - The type of elements in the array.
|
|
9
|
-
* @param
|
|
9
|
+
* @param array - The array from which to drop elements.
|
|
10
10
|
* @param itemsCount - The number of elements to drop from the beginning of the array.
|
|
11
|
-
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
|
|
12
11
|
* @returns A new array with the specified number of elements removed from the start.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
@@ -16,6 +15,6 @@
|
|
|
16
15
|
* const result = drop(array, 2);
|
|
17
16
|
* result will be [3, 4, 5] since the first two elements are dropped.
|
|
18
17
|
*/
|
|
19
|
-
declare function drop<T>(array: ArrayLike<T> | null | undefined,
|
|
18
|
+
declare function drop<T>(array: ArrayLike<T> | null | undefined, itemsCount?: number): T[];
|
|
20
19
|
//#endregion
|
|
21
20
|
export { drop };
|
|
@@ -3,10 +3,10 @@ const require_toInteger = require("../util/toInteger.js");
|
|
|
3
3
|
const require_toArray = require("../_internal/toArray.js");
|
|
4
4
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
5
5
|
//#region src/compat/array/drop.ts
|
|
6
|
-
function drop(
|
|
7
|
-
if (!require_isArrayLike.isArrayLike(
|
|
6
|
+
function drop(array, itemsCount = 1, guard) {
|
|
7
|
+
if (!require_isArrayLike.isArrayLike(array)) return [];
|
|
8
8
|
itemsCount = guard ? 1 : require_toInteger.toInteger(itemsCount);
|
|
9
|
-
return require_drop.drop(require_toArray.toArray(
|
|
9
|
+
return require_drop.drop(require_toArray.toArray(array), itemsCount);
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
exports.drop = drop;
|
|
@@ -3,10 +3,10 @@ import { toInteger } from "../util/toInteger.mjs";
|
|
|
3
3
|
import { toArray } from "../_internal/toArray.mjs";
|
|
4
4
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
5
5
|
//#region src/compat/array/drop.ts
|
|
6
|
-
function drop(
|
|
7
|
-
if (!isArrayLike(
|
|
6
|
+
function drop(array, itemsCount = 1, guard) {
|
|
7
|
+
if (!isArrayLike(array)) return [];
|
|
8
8
|
itemsCount = guard ? 1 : toInteger(itemsCount);
|
|
9
|
-
return drop$1(toArray(
|
|
9
|
+
return drop$1(toArray(array), itemsCount);
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
export { drop };
|
|
@@ -13,7 +13,7 @@ const require_matchesProperty = require("../predicate/matchesProperty.js");
|
|
|
13
13
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
14
14
|
*
|
|
15
15
|
* @template T - The type of elements in the array.
|
|
16
|
-
* @param
|
|
16
|
+
* @param array - The array from which to drop elements.
|
|
17
17
|
* @param predicate - A predicate function that determines
|
|
18
18
|
* whether to continue dropping elements. The function is called with each element, index, and array, and dropping
|
|
19
19
|
* continues as long as it returns true.
|
|
@@ -24,9 +24,9 @@ const require_matchesProperty = require("../predicate/matchesProperty.js");
|
|
|
24
24
|
* const result = dropRightWhile(array, (item, index, arr) => index >= 1);
|
|
25
25
|
* // Returns: [3]
|
|
26
26
|
*/
|
|
27
|
-
function dropRightWhile(
|
|
28
|
-
if (!require_isArrayLike.isArrayLike(
|
|
29
|
-
return dropRightWhileImpl(require_toArray.toArray(
|
|
27
|
+
function dropRightWhile(array, predicate = require_identity.identity) {
|
|
28
|
+
if (!require_isArrayLike.isArrayLike(array)) return [];
|
|
29
|
+
return dropRightWhileImpl(require_toArray.toArray(array), predicate);
|
|
30
30
|
}
|
|
31
31
|
function dropRightWhileImpl(arr, predicate) {
|
|
32
32
|
switch (typeof predicate) {
|
|
@@ -13,7 +13,7 @@ import { matchesProperty } from "../predicate/matchesProperty.mjs";
|
|
|
13
13
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
14
14
|
*
|
|
15
15
|
* @template T - The type of elements in the array.
|
|
16
|
-
* @param
|
|
16
|
+
* @param array - The array from which to drop elements.
|
|
17
17
|
* @param predicate - A predicate function that determines
|
|
18
18
|
* whether to continue dropping elements. The function is called with each element, index, and array, and dropping
|
|
19
19
|
* continues as long as it returns true.
|
|
@@ -24,9 +24,9 @@ import { matchesProperty } from "../predicate/matchesProperty.mjs";
|
|
|
24
24
|
* const result = dropRightWhile(array, (item, index, arr) => index >= 1);
|
|
25
25
|
* // Returns: [3]
|
|
26
26
|
*/
|
|
27
|
-
function dropRightWhile(
|
|
28
|
-
if (!isArrayLike(
|
|
29
|
-
return dropRightWhileImpl(toArray(
|
|
27
|
+
function dropRightWhile(array, predicate = identity) {
|
|
28
|
+
if (!isArrayLike(array)) return [];
|
|
29
|
+
return dropRightWhileImpl(toArray(array), predicate);
|
|
30
30
|
}
|
|
31
31
|
function dropRightWhileImpl(arr, predicate) {
|
|
32
32
|
switch (typeof predicate) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.48.1-dev.
|
|
3
|
+
"version": "1.48.1-dev.1883+3c6aa98f",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|