es-toolkit 1.24.0-dev.773 → 1.24.0-dev.774

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.
@@ -5,7 +5,7 @@
5
5
  * of elements removed from the start.
6
6
  *
7
7
  * @template T - The type of elements in the array.
8
- * @param { T[] | null | undefined} collection - - The array from which to drop elements.
8
+ * @param {ArrayLike<T> | null | undefined} collection - The array from which to drop elements.
9
9
  * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
10
10
  * @returns {T[]} A new array with the specified number of elements removed from the start.
11
11
  *
@@ -14,6 +14,6 @@
14
14
  * const result = drop(array, 2);
15
15
  * result will be [3, 4, 5] since the first two elements are dropped.
16
16
  */
17
- declare function drop<T>(collection: readonly T[] | null | undefined, itemsCount: number): T[];
17
+ declare function drop<T>(collection: ArrayLike<T> | null | undefined, itemsCount: number): T[];
18
18
 
19
19
  export { drop };
@@ -5,7 +5,7 @@
5
5
  * of elements removed from the start.
6
6
  *
7
7
  * @template T - The type of elements in the array.
8
- * @param { T[] | null | undefined} collection - - The array from which to drop elements.
8
+ * @param {ArrayLike<T> | null | undefined} collection - The array from which to drop elements.
9
9
  * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
10
10
  * @returns {T[]} A new array with the specified number of elements removed from the start.
11
11
  *
@@ -14,6 +14,6 @@
14
14
  * const result = drop(array, 2);
15
15
  * result will be [3, 4, 5] since the first two elements are dropped.
16
16
  */
17
- declare function drop<T>(collection: readonly T[] | null | undefined, itemsCount: number): T[];
17
+ declare function drop<T>(collection: ArrayLike<T> | null | undefined, itemsCount: number): T[];
18
18
 
19
19
  export { drop };
@@ -1,9 +1,11 @@
1
+ import { drop as drop$1 } from '../../array/drop.mjs';
2
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
3
+
1
4
  function drop(collection, itemsCount) {
2
- if (collection === null || collection === undefined) {
5
+ if (!isArrayLike(collection)) {
3
6
  return [];
4
7
  }
5
- itemsCount = Math.max(itemsCount, 0);
6
- return collection.slice(itemsCount);
8
+ return drop$1(Array.from(collection), itemsCount);
7
9
  }
8
10
 
9
11
  export { drop };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes a specified number of elements from the end of an array and returns the rest.
3
+ *
4
+ * This function takes an array and a number, and returns a new array with the specified number
5
+ * of elements removed from the end.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param {ArrayLike<T> | null | undefined} collection - The array from which to drop elements.
9
+ * @param {number} itemsCount - The number of elements to drop from the end of the array.
10
+ * @returns {T[]} A new array with the specified number of elements removed from the end.
11
+ *
12
+ * @example
13
+ * const array = [1, 2, 3, 4, 5];
14
+ * const result = dropRight(array, 2);
15
+ * // result will be [1, 2, 3] since the last two elements are dropped.
16
+ */
17
+ declare function dropRight<T>(collection: ArrayLike<T> | null | undefined, itemsCount: number): T[];
18
+
19
+ export { dropRight };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes a specified number of elements from the end of an array and returns the rest.
3
+ *
4
+ * This function takes an array and a number, and returns a new array with the specified number
5
+ * of elements removed from the end.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param {ArrayLike<T> | null | undefined} collection - The array from which to drop elements.
9
+ * @param {number} itemsCount - The number of elements to drop from the end of the array.
10
+ * @returns {T[]} A new array with the specified number of elements removed from the end.
11
+ *
12
+ * @example
13
+ * const array = [1, 2, 3, 4, 5];
14
+ * const result = dropRight(array, 2);
15
+ * // result will be [1, 2, 3] since the last two elements are dropped.
16
+ */
17
+ declare function dropRight<T>(collection: ArrayLike<T> | null | undefined, itemsCount: number): T[];
18
+
19
+ export { dropRight };
@@ -0,0 +1,11 @@
1
+ import { dropRight as dropRight$1 } from '../../array/dropRight.mjs';
2
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
3
+
4
+ function dropRight(collection, itemsCount) {
5
+ if (!isArrayLike(collection)) {
6
+ return [];
7
+ }
8
+ return dropRight$1(Array.from(collection), itemsCount);
9
+ }
10
+
11
+ export { dropRight };
@@ -2,7 +2,7 @@
2
2
  * Drops elements from the end of an array while the predicate function returns truthy.
3
3
  *
4
4
  * @template T - The type of elements in the array.
5
- * @param {T[]} arr - The array from which to drop elements.
5
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
6
6
  * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines
7
7
  * whether to continue dropping elements. The function is called with each element, index, and array, and dropping
8
8
  * continues as long as it returns true.
@@ -13,12 +13,12 @@
13
13
  * const result = dropRightWhile(array, x => x < 3);
14
14
  * result will be [5, 4, 3] since elements less than 3 are dropped.
15
15
  */
16
- declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
16
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
17
17
  /**
18
18
  * Drops elements from the end of an array while the specified object properties match.
19
19
  *
20
20
  * @template T - The type of elements in the array.
21
- * @param {T[]} arr - The array from which to drop elements.
21
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
22
22
  * @param {Partial<T>} objectToDrop - An object specifying the properties to match for dropping elements.
23
23
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
24
24
  *
@@ -27,12 +27,12 @@ declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item
27
27
  * const result = dropRightWhile(array, { a: 3 });
28
28
  * result will be [{ a: 1 }, { a: 2 }] since the last object matches the properties of the provided object.
29
29
  */
30
- declare function dropRightWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
30
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, objectToDrop: Partial<T>): T[];
31
31
  /**
32
32
  * Drops elements from the end of an array while the specified property matches a given value.
33
33
  *
34
34
  * @template T - The type of elements in the array.
35
- * @param {T[]} arr - The array from which to drop elements.
35
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
36
36
  * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.
37
37
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
38
38
  *
@@ -41,12 +41,12 @@ declare function dropRightWhile<T>(arr: readonly T[], objectToDrop: Partial<T>):
41
41
  * const result = dropRightWhile(array, ['id', 3]);
42
42
  * result will be [{ id: 1 }, { id: 2 }] since the last object has the id property matching the value 3.
43
43
  */
44
- declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unknown]): T[];
44
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: [keyof T, unknown]): T[];
45
45
  /**
46
46
  * Drops elements from the end of an array while the specified property name matches.
47
47
  *
48
48
  * @template T - The type of elements in the array.
49
- * @param {T[]} arr - The array from which to drop elements.
49
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
50
50
  * @param {string} propertyToDrop - The name of the property to match for dropping elements.
51
51
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
52
52
  *
@@ -55,6 +55,6 @@ declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: [keyof T,
55
55
  * const result = dropRightWhile(array, 'isActive');
56
56
  * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
57
57
  */
58
- declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: string): T[];
58
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: string): T[];
59
59
 
60
60
  export { dropRightWhile };
@@ -2,7 +2,7 @@
2
2
  * Drops elements from the end of an array while the predicate function returns truthy.
3
3
  *
4
4
  * @template T - The type of elements in the array.
5
- * @param {T[]} arr - The array from which to drop elements.
5
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
6
6
  * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines
7
7
  * whether to continue dropping elements. The function is called with each element, index, and array, and dropping
8
8
  * continues as long as it returns true.
@@ -13,12 +13,12 @@
13
13
  * const result = dropRightWhile(array, x => x < 3);
14
14
  * result will be [5, 4, 3] since elements less than 3 are dropped.
15
15
  */
16
- declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
16
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
17
17
  /**
18
18
  * Drops elements from the end of an array while the specified object properties match.
19
19
  *
20
20
  * @template T - The type of elements in the array.
21
- * @param {T[]} arr - The array from which to drop elements.
21
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
22
22
  * @param {Partial<T>} objectToDrop - An object specifying the properties to match for dropping elements.
23
23
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
24
24
  *
@@ -27,12 +27,12 @@ declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item
27
27
  * const result = dropRightWhile(array, { a: 3 });
28
28
  * result will be [{ a: 1 }, { a: 2 }] since the last object matches the properties of the provided object.
29
29
  */
30
- declare function dropRightWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
30
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, objectToDrop: Partial<T>): T[];
31
31
  /**
32
32
  * Drops elements from the end of an array while the specified property matches a given value.
33
33
  *
34
34
  * @template T - The type of elements in the array.
35
- * @param {T[]} arr - The array from which to drop elements.
35
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
36
36
  * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.
37
37
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
38
38
  *
@@ -41,12 +41,12 @@ declare function dropRightWhile<T>(arr: readonly T[], objectToDrop: Partial<T>):
41
41
  * const result = dropRightWhile(array, ['id', 3]);
42
42
  * result will be [{ id: 1 }, { id: 2 }] since the last object has the id property matching the value 3.
43
43
  */
44
- declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unknown]): T[];
44
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: [keyof T, unknown]): T[];
45
45
  /**
46
46
  * Drops elements from the end of an array while the specified property name matches.
47
47
  *
48
48
  * @template T - The type of elements in the array.
49
- * @param {T[]} arr - The array from which to drop elements.
49
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
50
50
  * @param {string} propertyToDrop - The name of the property to match for dropping elements.
51
51
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
52
52
  *
@@ -55,6 +55,6 @@ declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: [keyof T,
55
55
  * const result = dropRightWhile(array, 'isActive');
56
56
  * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
57
57
  */
58
- declare function dropRightWhile<T>(arr: readonly T[], propertyToDrop: string): T[];
58
+ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: string): T[];
59
59
 
60
60
  export { dropRightWhile };
@@ -1,9 +1,16 @@
1
1
  import { dropRightWhile as dropRightWhile$1 } from '../../array/dropRightWhile.mjs';
2
2
  import { property } from '../object/property.mjs';
3
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
3
4
  import { matches } from '../predicate/matches.mjs';
4
5
  import { matchesProperty } from '../predicate/matchesProperty.mjs';
5
6
 
6
7
  function dropRightWhile(arr, predicate) {
8
+ if (!isArrayLike(arr)) {
9
+ return [];
10
+ }
11
+ return dropRightWhileImpl(Array.from(arr), predicate);
12
+ }
13
+ function dropRightWhileImpl(arr, predicate) {
7
14
  switch (typeof predicate) {
8
15
  case 'function': {
9
16
  return dropRightWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
@@ -2,7 +2,7 @@
2
2
  * Drops elements from the beginning of an array while the predicate function returns truthy.
3
3
  *
4
4
  * @template T - The type of elements in the array.
5
- * @param {T[]} arr - The array from which to drop elements.
5
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
6
6
  * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines
7
7
  * whether to continue dropping elements. The function is called with each element, index, and array, and dropping
8
8
  * continues as long as it returns true.
@@ -13,12 +13,12 @@
13
13
  * const result = dropWhile(array, x => x < 3);
14
14
  * result will be [3, 4, 5] since elements less than 3 are dropped.
15
15
  */
16
- declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
16
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
17
17
  /**
18
18
  * Drops elements from the beginning of an array while the specified object properties match.
19
19
  *
20
20
  * @template T - The type of elements in the array.
21
- * @param {T[]} arr - The array from which to drop elements.
21
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
22
22
  * @param {Partial<T>} objectToDrop - An object specifying the properties to match for dropping elements.
23
23
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
24
24
  *
@@ -27,12 +27,12 @@ declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T,
27
27
  * const result = dropWhile(array, { a: 1 });
28
28
  * result will be [{ a: 2 }, { a: 3 }] since the first object matches the properties of the provided object.
29
29
  */
30
- declare function dropWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
30
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, objectToDrop: Partial<T>): T[];
31
31
  /**
32
32
  * Drops elements from the beginning of an array while the specified property matches a given value.
33
33
  *
34
34
  * @template T - The type of elements in the array.
35
- * @param {T[]} arr - The array from which to drop elements.
35
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
36
36
  * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.
37
37
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
38
38
  *
@@ -41,12 +41,12 @@ declare function dropWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
41
41
  * const result = dropWhile(array, ['id', 1]);
42
42
  * result will be [{ id: 2 }, { id: 3 }] since the first object has the id property matching the value 1.
43
43
  */
44
- declare function dropWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unknown]): T[];
44
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: [keyof T, unknown]): T[];
45
45
  /**
46
46
  * Drops elements from the beginning of an array while the specified property name matches.
47
47
  *
48
48
  * @template T - The type of elements in the array.
49
- * @param {T[]} arr - The array from which to drop elements.
49
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
50
50
  * @param {string} propertyToDrop - The name of the property to match for dropping elements.
51
51
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
52
52
  *
@@ -55,6 +55,6 @@ declare function dropWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unkno
55
55
  * const result = dropWhile(array, 'isActive');
56
56
  * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
57
57
  */
58
- declare function dropWhile<T>(arr: readonly T[], propertyToDrop: string): T[];
58
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: string): T[];
59
59
 
60
60
  export { dropWhile };
@@ -2,7 +2,7 @@
2
2
  * Drops elements from the beginning of an array while the predicate function returns truthy.
3
3
  *
4
4
  * @template T - The type of elements in the array.
5
- * @param {T[]} arr - The array from which to drop elements.
5
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
6
6
  * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines
7
7
  * whether to continue dropping elements. The function is called with each element, index, and array, and dropping
8
8
  * continues as long as it returns true.
@@ -13,12 +13,12 @@
13
13
  * const result = dropWhile(array, x => x < 3);
14
14
  * result will be [3, 4, 5] since elements less than 3 are dropped.
15
15
  */
16
- declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
16
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown): T[];
17
17
  /**
18
18
  * Drops elements from the beginning of an array while the specified object properties match.
19
19
  *
20
20
  * @template T - The type of elements in the array.
21
- * @param {T[]} arr - The array from which to drop elements.
21
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
22
22
  * @param {Partial<T>} objectToDrop - An object specifying the properties to match for dropping elements.
23
23
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
24
24
  *
@@ -27,12 +27,12 @@ declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T,
27
27
  * const result = dropWhile(array, { a: 1 });
28
28
  * result will be [{ a: 2 }, { a: 3 }] since the first object matches the properties of the provided object.
29
29
  */
30
- declare function dropWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
30
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, objectToDrop: Partial<T>): T[];
31
31
  /**
32
32
  * Drops elements from the beginning of an array while the specified property matches a given value.
33
33
  *
34
34
  * @template T - The type of elements in the array.
35
- * @param {T[]} arr - The array from which to drop elements.
35
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
36
36
  * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.
37
37
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
38
38
  *
@@ -41,12 +41,12 @@ declare function dropWhile<T>(arr: readonly T[], objectToDrop: Partial<T>): T[];
41
41
  * const result = dropWhile(array, ['id', 1]);
42
42
  * result will be [{ id: 2 }, { id: 3 }] since the first object has the id property matching the value 1.
43
43
  */
44
- declare function dropWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unknown]): T[];
44
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: [keyof T, unknown]): T[];
45
45
  /**
46
46
  * Drops elements from the beginning of an array while the specified property name matches.
47
47
  *
48
48
  * @template T - The type of elements in the array.
49
- * @param {T[]} arr - The array from which to drop elements.
49
+ * @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
50
50
  * @param {string} propertyToDrop - The name of the property to match for dropping elements.
51
51
  * @returns {T[]} A new array with the elements remaining after the predicate returns false.
52
52
  *
@@ -55,6 +55,6 @@ declare function dropWhile<T>(arr: readonly T[], propertyToDrop: [keyof T, unkno
55
55
  * const result = dropWhile(array, 'isActive');
56
56
  * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
57
57
  */
58
- declare function dropWhile<T>(arr: readonly T[], propertyToDrop: string): T[];
58
+ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: string): T[];
59
59
 
60
60
  export { dropWhile };
@@ -1,9 +1,16 @@
1
1
  import { dropWhile as dropWhile$1 } from '../../array/dropWhile.mjs';
2
2
  import { property } from '../object/property.mjs';
3
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
3
4
  import { matches } from '../predicate/matches.mjs';
4
5
  import { matchesProperty } from '../predicate/matchesProperty.mjs';
5
6
 
6
7
  function dropWhile(arr, predicate) {
8
+ if (!isArrayLike(arr)) {
9
+ return [];
10
+ }
11
+ return dropWhileImpl(Array.from(arr), predicate);
12
+ }
13
+ function dropWhileImpl(arr, predicate) {
7
14
  switch (typeof predicate) {
8
15
  case 'function': {
9
16
  return dropWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
@@ -3,7 +3,6 @@ export { compact } from '../array/compact.mjs';
3
3
  export { countBy } from '../array/countBy.mjs';
4
4
  export { differenceBy } from '../array/differenceBy.mjs';
5
5
  export { differenceWith } from '../array/differenceWith.mjs';
6
- export { dropRight } from '../array/dropRight.mjs';
7
6
  export { flatMap } from '../array/flatMap.mjs';
8
7
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
9
8
  export { forEachRight } from '../array/forEachRight.mjs';
@@ -94,6 +93,7 @@ export { chunk } from './array/chunk.mjs';
94
93
  export { concat } from './array/concat.mjs';
95
94
  export { difference } from './array/difference.mjs';
96
95
  export { drop } from './array/drop.mjs';
96
+ export { dropRight } from './array/dropRight.mjs';
97
97
  export { dropRightWhile } from './array/dropRightWhile.mjs';
98
98
  export { dropWhile } from './array/dropWhile.mjs';
99
99
  export { every } from './array/every.mjs';
@@ -3,7 +3,6 @@ export { compact } from '../array/compact.js';
3
3
  export { countBy } from '../array/countBy.js';
4
4
  export { differenceBy } from '../array/differenceBy.js';
5
5
  export { differenceWith } from '../array/differenceWith.js';
6
- export { dropRight } from '../array/dropRight.js';
7
6
  export { flatMap } from '../array/flatMap.js';
8
7
  export { flatMapDeep } from '../array/flatMapDeep.js';
9
8
  export { forEachRight } from '../array/forEachRight.js';
@@ -94,6 +93,7 @@ export { chunk } from './array/chunk.js';
94
93
  export { concat } from './array/concat.js';
95
94
  export { difference } from './array/difference.js';
96
95
  export { drop } from './array/drop.js';
96
+ export { dropRight } from './array/dropRight.js';
97
97
  export { dropRightWhile } from './array/dropRightWhile.js';
98
98
  export { dropWhile } from './array/dropWhile.js';
99
99
  export { every } from './array/every.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('../_chunk/zipWith-wpjySR.js');
5
+ const zipWith = require('../_chunk/zipWith-DTRoEV.js');
6
6
  const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const unary = require('../_chunk/unary-BZ5Ixo.js');
8
8
  const noop = require('../_chunk/noop-2IwLUk.js');
@@ -56,11 +56,17 @@ function difference(arr, ...values) {
56
56
  }
57
57
 
58
58
  function drop(collection, itemsCount) {
59
- if (collection === null || collection === undefined) {
59
+ if (!isArrayLike(collection)) {
60
60
  return [];
61
61
  }
62
- itemsCount = Math.max(itemsCount, 0);
63
- return collection.slice(itemsCount);
62
+ return zipWith.drop(Array.from(collection), itemsCount);
63
+ }
64
+
65
+ function dropRight(collection, itemsCount) {
66
+ if (!isArrayLike(collection)) {
67
+ return [];
68
+ }
69
+ return zipWith.dropRight(Array.from(collection), itemsCount);
64
70
  }
65
71
 
66
72
  function isDeepKey(key) {
@@ -394,6 +400,12 @@ function matchesProperty(property, source) {
394
400
  }
395
401
 
396
402
  function dropRightWhile(arr, predicate) {
403
+ if (!isArrayLike(arr)) {
404
+ return [];
405
+ }
406
+ return dropRightWhileImpl(Array.from(arr), predicate);
407
+ }
408
+ function dropRightWhileImpl(arr, predicate) {
397
409
  switch (typeof predicate) {
398
410
  case 'function': {
399
411
  return zipWith.dropRightWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
@@ -415,6 +427,12 @@ function dropRightWhile(arr, predicate) {
415
427
  }
416
428
 
417
429
  function dropWhile(arr, predicate) {
430
+ if (!isArrayLike(arr)) {
431
+ return [];
432
+ }
433
+ return dropWhileImpl(Array.from(arr), predicate);
434
+ }
435
+ function dropWhileImpl(arr, predicate) {
418
436
  switch (typeof predicate) {
419
437
  case 'function': {
420
438
  return zipWith.dropWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
@@ -2092,7 +2110,6 @@ exports.compact = zipWith.compact;
2092
2110
  exports.countBy = zipWith.countBy;
2093
2111
  exports.differenceBy = zipWith.differenceBy;
2094
2112
  exports.differenceWith = zipWith.differenceWith;
2095
- exports.dropRight = zipWith.dropRight;
2096
2113
  exports.first = zipWith.head;
2097
2114
  exports.flatMap = zipWith.flatMap;
2098
2115
  exports.flatMapDeep = zipWith.flatMapDeep;
@@ -2204,6 +2221,7 @@ exports.defaults = defaults;
2204
2221
  exports.defer = defer;
2205
2222
  exports.difference = difference;
2206
2223
  exports.drop = drop;
2224
+ exports.dropRight = dropRight;
2207
2225
  exports.dropRightWhile = dropRightWhile;
2208
2226
  exports.dropWhile = dropWhile;
2209
2227
  exports.endsWith = endsWith;
@@ -3,7 +3,6 @@ export { compact } from '../array/compact.mjs';
3
3
  export { countBy } from '../array/countBy.mjs';
4
4
  export { differenceBy } from '../array/differenceBy.mjs';
5
5
  export { differenceWith } from '../array/differenceWith.mjs';
6
- export { dropRight } from '../array/dropRight.mjs';
7
6
  export { flatMap } from '../array/flatMap.mjs';
8
7
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
9
8
  export { forEachRight } from '../array/forEachRight.mjs';
@@ -96,6 +95,7 @@ export { chunk } from './array/chunk.mjs';
96
95
  export { concat } from './array/concat.mjs';
97
96
  export { difference } from './array/difference.mjs';
98
97
  export { drop } from './array/drop.mjs';
98
+ export { dropRight } from './array/dropRight.mjs';
99
99
  export { dropRightWhile } from './array/dropRightWhile.mjs';
100
100
  export { dropWhile } from './array/dropWhile.mjs';
101
101
  export { every } from './array/every.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-wpjySR.js');
5
+ const zipWith = require('./_chunk/zipWith-DTRoEV.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-BZ5Ixo.js');
@@ -28,6 +28,7 @@ exports.countBy = zipWith.countBy;
28
28
  exports.difference = zipWith.difference;
29
29
  exports.differenceBy = zipWith.differenceBy;
30
30
  exports.differenceWith = zipWith.differenceWith;
31
+ exports.drop = zipWith.drop;
31
32
  exports.dropRight = zipWith.dropRight;
32
33
  exports.dropRightWhile = zipWith.dropRightWhile;
33
34
  exports.dropWhile = zipWith.dropWhile;
@@ -74,7 +75,6 @@ exports.xorWith = zipWith.xorWith;
74
75
  exports.zip = zipWith.zip;
75
76
  exports.zipObject = zipWith.zipObject;
76
77
  exports.zipWith = zipWith.zipWith;
77
- exports.drop = array_index.drop;
78
78
  exports.orderBy = array_index.orderBy;
79
79
  exports.sortBy = array_index.sortBy;
80
80
  exports.AbortError = promise_index.AbortError;
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.24.0-dev.773+27403452",
4
+ "version": "1.24.0-dev.774+c95d40f4",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {