es-toolkit 1.30.1-dev.978 → 1.30.1-dev.980

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,24 @@
1
+ /**
2
+ * Reverses the elements of an array in place.
3
+ *
4
+ * This function takes an array and reverses its elements in place, modifying the original array.
5
+ * If the input is `null` or `undefined`, it returns the input as is.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param {T[] | null | undefined} array - The array to reverse. If `null` or `undefined`, the input is returned as is.
9
+ * @returns {T[] | null | undefined} The reversed array, or `null`/`undefined` if the input was `null`/`undefined`.
10
+ *
11
+ * @example
12
+ * const array = [1, 2, 3, 4, 5];
13
+ * const reversedArray = reverse(array);
14
+ * // reversedArray is [5, 4, 3, 2, 1], and array is also modified to [5, 4, 3, 2, 1].
15
+ *
16
+ * const emptyArray = reverse([]);
17
+ * // emptyArray is [].
18
+ *
19
+ * const nullArray = reverse(null);
20
+ * // nullArray is null.
21
+ */
22
+ declare function reverse<T>(array: T[] | null | undefined): T[] | null | undefined;
23
+
24
+ export { reverse };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Reverses the elements of an array in place.
3
+ *
4
+ * This function takes an array and reverses its elements in place, modifying the original array.
5
+ * If the input is `null` or `undefined`, it returns the input as is.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param {T[] | null | undefined} array - The array to reverse. If `null` or `undefined`, the input is returned as is.
9
+ * @returns {T[] | null | undefined} The reversed array, or `null`/`undefined` if the input was `null`/`undefined`.
10
+ *
11
+ * @example
12
+ * const array = [1, 2, 3, 4, 5];
13
+ * const reversedArray = reverse(array);
14
+ * // reversedArray is [5, 4, 3, 2, 1], and array is also modified to [5, 4, 3, 2, 1].
15
+ *
16
+ * const emptyArray = reverse([]);
17
+ * // emptyArray is [].
18
+ *
19
+ * const nullArray = reverse(null);
20
+ * // nullArray is null.
21
+ */
22
+ declare function reverse<T>(array: T[] | null | undefined): T[] | null | undefined;
23
+
24
+ export { reverse };
@@ -0,0 +1,8 @@
1
+ function reverse(array) {
2
+ if (array == null) {
3
+ return array;
4
+ }
5
+ return array.reverse();
6
+ }
7
+
8
+ export { reverse };
@@ -97,6 +97,7 @@ export { map } from './array/map.mjs';
97
97
  export { nth } from './array/nth.mjs';
98
98
  export { orderBy } from './array/orderBy.mjs';
99
99
  export { pull } from './array/pull.mjs';
100
+ export { reverse } from './array/reverse.mjs';
100
101
  export { sample } from './array/sample.mjs';
101
102
  export { size } from './array/size.mjs';
102
103
  export { slice } from './array/slice.mjs';
@@ -97,6 +97,7 @@ export { map } from './array/map.js';
97
97
  export { nth } from './array/nth.js';
98
98
  export { orderBy } from './array/orderBy.js';
99
99
  export { pull } from './array/pull.js';
100
+ export { reverse } from './array/reverse.js';
100
101
  export { sample } from './array/sample.js';
101
102
  export { size } from './array/size.js';
102
103
  export { slice } from './array/slice.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('../_chunk/zipWith-M-SG50.js');
5
+ const zipWith = require('../_chunk/zipWith-CviBZV.js');
6
6
  const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const unary = require('../_chunk/unary-B6qG7C.js');
8
8
  const noop = require('../_chunk/noop-2IwLUk.js');
@@ -1168,6 +1168,13 @@ function pull(arr, ...valuesToRemove) {
1168
1168
  return zipWith.pull(arr, flatten(valuesToRemove));
1169
1169
  }
1170
1170
 
1171
+ function reverse(array) {
1172
+ if (array == null) {
1173
+ return array;
1174
+ }
1175
+ return array.reverse();
1176
+ }
1177
+
1171
1178
  function sample(collection) {
1172
1179
  if (collection == null) {
1173
1180
  return undefined;
@@ -3244,6 +3251,7 @@ exports.rearg = rearg;
3244
3251
  exports.repeat = repeat;
3245
3252
  exports.replace = replace;
3246
3253
  exports.rest = rest;
3254
+ exports.reverse = reverse;
3247
3255
  exports.round = round;
3248
3256
  exports.sample = sample;
3249
3257
  exports.set = set;
@@ -99,6 +99,7 @@ export { map } from './array/map.mjs';
99
99
  export { nth } from './array/nth.mjs';
100
100
  export { orderBy } from './array/orderBy.mjs';
101
101
  export { pull } from './array/pull.mjs';
102
+ export { reverse } from './array/reverse.mjs';
102
103
  export { sample } from './array/sample.mjs';
103
104
  export { size } from './array/size.mjs';
104
105
  export { slice } from './array/slice.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-M-SG50.js');
5
+ const zipWith = require('./_chunk/zipWith-CviBZV.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-B6qG7C.js');
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.30.1-dev.978+9f8b6691",
4
+ "version": "1.30.1-dev.980+a6f80810",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {