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

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.
@@ -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(itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,SAAO,IAAI,MAAM,UAAU;AAC7B;","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 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":[]}
@@ -0,0 +1,13 @@
1
+ // src/array/dropRight.ts
2
+ function dropRight(arr, itemsCount) {
3
+ const count = Math.min(-itemsCount, 0);
4
+ if (count === 0) {
5
+ return arr.slice();
6
+ }
7
+ return arr.slice(0, count);
8
+ }
9
+
10
+ export {
11
+ dropRight
12
+ };
13
+ //# sourceMappingURL=chunk-WRSDEUO4.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 return arr.slice(0, -itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,SAAO,IAAI,MAAM,GAAG,CAAC,UAAU;AACjC;","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 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":[]}
@@ -211,12 +211,16 @@ function differenceWith(firstArr, secondArr, areItemsEqual) {
211
211
 
212
212
  // src/array/drop.ts
213
213
  function drop(arr, itemsCount) {
214
- return arr.slice(itemsCount);
214
+ return arr.slice(Math.max(itemsCount, 0));
215
215
  }
216
216
 
217
217
  // src/array/dropRight.ts
218
218
  function dropRight(arr, itemsCount) {
219
- return arr.slice(0, -itemsCount);
219
+ const count = Math.min(-itemsCount, 0);
220
+ if (count === 0) {
221
+ return arr.slice();
222
+ }
223
+ return arr.slice(0, count);
220
224
  }
221
225
 
222
226
  // src/array/dropRightWhile.ts