es-toolkit 1.26.1-dev.845 → 1.26.1-dev.847

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,16 @@
1
+ /**
2
+ * Gathers elements in the same position in an internal array
3
+ * from a grouped array of elements and returns them as a new array.
4
+ *
5
+ * @template T - The type of elements in the nested array.
6
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip.
7
+ * @returns {T[][]} A new array of unzipped elements.
8
+ *
9
+ * @example
10
+ * const zipped = [['a', true, 1],['b', false, 2]];
11
+ * const result = unzip(zipped);
12
+ * // result will be [['a', 'b'], [true, false], [1, 2]]
13
+ */
14
+ declare function unzip<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
15
+
16
+ export { unzip };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Gathers elements in the same position in an internal array
3
+ * from a grouped array of elements and returns them as a new array.
4
+ *
5
+ * @template T - The type of elements in the nested array.
6
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip.
7
+ * @returns {T[][]} A new array of unzipped elements.
8
+ *
9
+ * @example
10
+ * const zipped = [['a', true, 1],['b', false, 2]];
11
+ * const result = unzip(zipped);
12
+ * // result will be [['a', 'b'], [true, false], [1, 2]]
13
+ */
14
+ declare function unzip<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
15
+
16
+ export { unzip };
@@ -0,0 +1,14 @@
1
+ import { unzip as unzip$1 } from '../../array/unzip.mjs';
2
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
3
+
4
+ function unzip(array) {
5
+ if (!isArrayLikeObject(array) || !array.length) {
6
+ return [];
7
+ }
8
+ if (Array.isArray(array)) {
9
+ return unzip$1(array);
10
+ }
11
+ return unzip$1(Array.from(array, value => Array.from(value)));
12
+ }
13
+
14
+ export { unzip };
@@ -23,7 +23,6 @@ export { unionBy } from '../array/unionBy.mjs';
23
23
  export { unionWith } from '../array/unionWith.mjs';
24
24
  export { uniqBy } from '../array/uniqBy.mjs';
25
25
  export { uniqWith } from '../array/uniqWith.mjs';
26
- export { unzip } from '../array/unzip.mjs';
27
26
  export { unzipWith } from '../array/unzipWith.mjs';
28
27
  export { xor } from '../array/xor.mjs';
29
28
  export { xorBy } from '../array/xorBy.mjs';
@@ -115,6 +114,7 @@ export { tail } from './array/tail.mjs';
115
114
  export { take } from './array/take.mjs';
116
115
  export { takeRight } from './array/takeRight.mjs';
117
116
  export { uniq } from './array/uniq.mjs';
117
+ export { unzip } from './array/unzip.mjs';
118
118
  export { without } from './array/without.mjs';
119
119
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
120
120
  export { ary } from './function/ary.mjs';
@@ -23,7 +23,6 @@ export { unionBy } from '../array/unionBy.js';
23
23
  export { unionWith } from '../array/unionWith.js';
24
24
  export { uniqBy } from '../array/uniqBy.js';
25
25
  export { uniqWith } from '../array/uniqWith.js';
26
- export { unzip } from '../array/unzip.js';
27
26
  export { unzipWith } from '../array/unzipWith.js';
28
27
  export { xor } from '../array/xor.js';
29
28
  export { xorBy } from '../array/xorBy.js';
@@ -115,6 +114,7 @@ export { tail } from './array/tail.js';
115
114
  export { take } from './array/take.js';
116
115
  export { takeRight } from './array/takeRight.js';
117
116
  export { uniq } from './array/uniq.js';
117
+ export { unzip } from './array/unzip.js';
118
118
  export { without } from './array/without.js';
119
119
  export { zipObjectDeep } from './array/zipObjectDeep.js';
120
120
  export { ary } from './function/ary.js';
@@ -1157,6 +1157,16 @@ function uniq(arr) {
1157
1157
  return zipWith.uniq(Array.from(arr));
1158
1158
  }
1159
1159
 
1160
+ function unzip(array) {
1161
+ if (!isArrayLikeObject(array) || !array.length) {
1162
+ return [];
1163
+ }
1164
+ if (Array.isArray(array)) {
1165
+ return zipWith.unzip(array);
1166
+ }
1167
+ return zipWith.unzip(Array.from(array, value => Array.from(value)));
1168
+ }
1169
+
1160
1170
  function without(array, ...values) {
1161
1171
  if (!isArrayLikeObject(array)) {
1162
1172
  return [];
@@ -2461,7 +2471,6 @@ exports.unionBy = zipWith.unionBy;
2461
2471
  exports.unionWith = zipWith.unionWith;
2462
2472
  exports.uniqBy = zipWith.uniqBy;
2463
2473
  exports.uniqWith = zipWith.uniqWith;
2464
- exports.unzip = zipWith.unzip;
2465
2474
  exports.unzipWith = zipWith.unzipWith;
2466
2475
  exports.xor = zipWith.xor;
2467
2476
  exports.xorBy = zipWith.xorBy;
@@ -2660,6 +2669,7 @@ exports.trimStart = trimStart;
2660
2669
  exports.uniq = uniq;
2661
2670
  exports.uniqueId = uniqueId;
2662
2671
  exports.unset = unset;
2672
+ exports.unzip = unzip;
2663
2673
  exports.upperCase = upperCase;
2664
2674
  exports.without = without;
2665
2675
  exports.zipObjectDeep = zipObjectDeep;
@@ -23,7 +23,6 @@ export { unionBy } from '../array/unionBy.mjs';
23
23
  export { unionWith } from '../array/unionWith.mjs';
24
24
  export { uniqBy } from '../array/uniqBy.mjs';
25
25
  export { uniqWith } from '../array/uniqWith.mjs';
26
- export { unzip } from '../array/unzip.mjs';
27
26
  export { unzipWith } from '../array/unzipWith.mjs';
28
27
  export { xor } from '../array/xor.mjs';
29
28
  export { xorBy } from '../array/xorBy.mjs';
@@ -117,6 +116,7 @@ export { tail } from './array/tail.mjs';
117
116
  export { take } from './array/take.mjs';
118
117
  export { takeRight } from './array/takeRight.mjs';
119
118
  export { uniq } from './array/uniq.mjs';
119
+ export { unzip } from './array/unzip.mjs';
120
120
  export { without } from './array/without.mjs';
121
121
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
122
122
  export { ary } from './function/ary.mjs';
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.26.1-dev.845+b6ec80d2",
4
+ "version": "1.26.1-dev.847+5b9e9656",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {