es-toolkit 1.10.1-dev.257 → 1.10.1-dev.258

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,10 @@
1
+ // src/array/drop.ts
2
+ function drop(arr, itemsCount) {
3
+ itemsCount = Math.max(itemsCount, 0);
4
+ return arr.slice(itemsCount);
5
+ }
6
+
7
+ export {
8
+ drop
9
+ };
10
+ //# sourceMappingURL=chunk-3EZAFZG3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(Math.max(itemsCount, 0));\n}\n"],"mappings":";AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,SAAO,IAAI,MAAM,KAAK,IAAI,YAAY,CAAC,CAAC;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.max(itemsCount, 0);\n\n return arr.slice(itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,eAAa,KAAK,IAAI,YAAY,CAAC;AAEnC,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
@@ -0,0 +1,13 @@
1
+ // src/array/dropRight.ts
2
+ function dropRight(arr, itemsCount) {
3
+ itemsCount = Math.min(-itemsCount, 0);
4
+ if (itemsCount === 0) {
5
+ return arr.slice();
6
+ }
7
+ return arr.slice(0, itemsCount);
8
+ }
9
+
10
+ export {
11
+ dropRight
12
+ };
13
+ //# sourceMappingURL=chunk-OXZCMC5I.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n const count = Math.min(-itemsCount, 0);\n if (count === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, count);\n}\n"],"mappings":";AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,QAAM,QAAQ,KAAK,IAAI,CAAC,YAAY,CAAC;AACrC,MAAI,UAAU,GAAG;AACf,WAAO,IAAI,MAAM;AAAA,EACnB;AAEA,SAAO,IAAI,MAAM,GAAG,KAAK;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.min(-itemsCount, 0);\n\n if (itemsCount === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,eAAa,KAAK,IAAI,CAAC,YAAY,CAAC;AAEpC,MAAI,eAAe,GAAG;AACpB,WAAO,IAAI,MAAM;AAAA,EACnB;AAEA,SAAO,IAAI,MAAM,GAAG,UAAU;AAChC;","names":[]}
@@ -211,16 +211,17 @@ function differenceWith(firstArr, secondArr, areItemsEqual) {
211
211
 
212
212
  // src/array/drop.ts
213
213
  function drop(arr, itemsCount) {
214
- return arr.slice(Math.max(itemsCount, 0));
214
+ itemsCount = Math.max(itemsCount, 0);
215
+ return arr.slice(itemsCount);
215
216
  }
216
217
 
217
218
  // src/array/dropRight.ts
218
219
  function dropRight(arr, itemsCount) {
219
- const count = Math.min(-itemsCount, 0);
220
- if (count === 0) {
220
+ itemsCount = Math.min(-itemsCount, 0);
221
+ if (itemsCount === 0) {
221
222
  return arr.slice();
222
223
  }
223
- return arr.slice(0, count);
224
+ return arr.slice(0, itemsCount);
224
225
  }
225
226
 
226
227
  // src/array/dropRightWhile.ts