es-toolkit 1.19.0-dev.607 → 1.19.0-dev.608

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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes a specified number of elements from the beginning 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 start.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param { T[] | null | undefined} collection - - The array from which to drop elements.
9
+ * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
10
+ * @returns {T[]} A new array with the specified number of elements removed from the start.
11
+ *
12
+ * @example
13
+ * const array = [1, 2, 3, 4, 5];
14
+ * const result = drop(array, 2);
15
+ * result will be [3, 4, 5] since the first two elements are dropped.
16
+ */
17
+ declare function drop<T>(collection: readonly T[] | null | undefined, itemsCount: number): T[];
18
+
19
+ export { drop };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes a specified number of elements from the beginning 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 start.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param { T[] | null | undefined} collection - - The array from which to drop elements.
9
+ * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
10
+ * @returns {T[]} A new array with the specified number of elements removed from the start.
11
+ *
12
+ * @example
13
+ * const array = [1, 2, 3, 4, 5];
14
+ * const result = drop(array, 2);
15
+ * result will be [3, 4, 5] since the first two elements are dropped.
16
+ */
17
+ declare function drop<T>(collection: readonly T[] | null | undefined, itemsCount: number): T[];
18
+
19
+ export { drop };
@@ -0,0 +1,9 @@
1
+ function drop(collection, itemsCount) {
2
+ if (collection === null || collection === undefined) {
3
+ return [];
4
+ }
5
+ itemsCount = Math.max(itemsCount, 0);
6
+ return collection.slice(itemsCount);
7
+ }
8
+
9
+ export { drop };
@@ -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 { drop } from '../array/drop.mjs';
7
6
  export { dropRight } from '../array/dropRight.mjs';
8
7
  export { dropRightWhile } from '../array/dropRightWhile.mjs';
9
8
  export { dropWhile } from '../array/dropWhile.mjs';
@@ -102,6 +101,7 @@ export { castArray } from './array/castArray.mjs';
102
101
  export { chunk } from './array/chunk.mjs';
103
102
  export { concat } from './array/concat.mjs';
104
103
  export { difference } from './array/difference.mjs';
104
+ export { drop } from './array/drop.mjs';
105
105
  export { fill } from './array/fill.mjs';
106
106
  export { find } from './array/find.mjs';
107
107
  export { findIndex } from './array/findIndex.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 { drop } from '../array/drop.js';
7
6
  export { dropRight } from '../array/dropRight.js';
8
7
  export { dropRightWhile } from '../array/dropRightWhile.js';
9
8
  export { dropWhile } from '../array/dropWhile.js';
@@ -102,6 +101,7 @@ export { castArray } from './array/castArray.js';
102
101
  export { chunk } from './array/chunk.js';
103
102
  export { concat } from './array/concat.js';
104
103
  export { difference } from './array/difference.js';
104
+ export { drop } from './array/drop.js';
105
105
  export { fill } from './array/fill.js';
106
106
  export { find } from './array/find.js';
107
107
  export { findIndex } from './array/findIndex.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('../_chunk/zipWith-B-5AMf.js');
5
+ const zipWith = require('../_chunk/zipWith-BgnHwx.js');
6
6
  const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const rest$1 = require('../_chunk/rest-CXt9w3.js');
8
8
  const range = require('../_chunk/range-BXlMmn.js');
@@ -37,6 +37,14 @@ function difference(arr, ...values) {
37
37
  return zipWith.difference(arr1, arr2);
38
38
  }
39
39
 
40
+ function drop(collection, itemsCount) {
41
+ if (collection === null || collection === undefined) {
42
+ return [];
43
+ }
44
+ itemsCount = Math.max(itemsCount, 0);
45
+ return collection.slice(itemsCount);
46
+ }
47
+
40
48
  function fill(array, value, start = 0, end = array.length) {
41
49
  start = Math.floor(start);
42
50
  end = Math.floor(end);
@@ -1432,7 +1440,6 @@ exports.compact = zipWith.compact;
1432
1440
  exports.countBy = zipWith.countBy;
1433
1441
  exports.differenceBy = zipWith.differenceBy;
1434
1442
  exports.differenceWith = zipWith.differenceWith;
1435
- exports.drop = zipWith.drop;
1436
1443
  exports.dropRight = zipWith.dropRight;
1437
1444
  exports.dropRightWhile = zipWith.dropRightWhile;
1438
1445
  exports.dropWhile = zipWith.dropWhile;
@@ -1542,6 +1549,7 @@ exports.conforms = conforms;
1542
1549
  exports.conformsTo = conformsTo;
1543
1550
  exports.curry = curry;
1544
1551
  exports.difference = difference;
1552
+ exports.drop = drop;
1545
1553
  exports.endsWith = endsWith;
1546
1554
  exports.fill = fill;
1547
1555
  exports.find = find;
@@ -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 { drop } from '../array/drop.mjs';
7
6
  export { dropRight } from '../array/dropRight.mjs';
8
7
  export { dropRightWhile } from '../array/dropRightWhile.mjs';
9
8
  export { dropWhile } from '../array/dropWhile.mjs';
@@ -103,6 +102,7 @@ export { castArray } from './array/castArray.mjs';
103
102
  export { chunk } from './array/chunk.mjs';
104
103
  export { concat } from './array/concat.mjs';
105
104
  export { difference } from './array/difference.mjs';
105
+ export { drop } from './array/drop.mjs';
106
106
  export { fill } from './array/fill.mjs';
107
107
  export { find } from './array/find.mjs';
108
108
  export { findIndex } from './array/findIndex.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-B-5AMf.js');
5
+ const zipWith = require('./_chunk/zipWith-BgnHwx.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const promise_index = require('./_chunk/index-BGZDR9.js');
8
8
  const rest = require('./_chunk/rest-CXt9w3.js');
@@ -26,7 +26,6 @@ exports.countBy = zipWith.countBy;
26
26
  exports.difference = zipWith.difference;
27
27
  exports.differenceBy = zipWith.differenceBy;
28
28
  exports.differenceWith = zipWith.differenceWith;
29
- exports.drop = zipWith.drop;
30
29
  exports.dropRight = zipWith.dropRight;
31
30
  exports.dropRightWhile = zipWith.dropRightWhile;
32
31
  exports.dropWhile = zipWith.dropWhile;
@@ -73,6 +72,7 @@ exports.xorWith = zipWith.xorWith;
73
72
  exports.zip = zipWith.zip;
74
73
  exports.zipObject = zipWith.zipObject;
75
74
  exports.zipWith = zipWith.zipWith;
75
+ exports.drop = array_index.drop;
76
76
  exports.orderBy = array_index.orderBy;
77
77
  exports.sortBy = array_index.sortBy;
78
78
  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.19.0-dev.607+c92faba7",
4
+ "version": "1.19.0-dev.608+5dea53fd",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {