es-toolkit 1.36.0-dev.1230 → 1.36.0-dev.1232

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,78 @@
1
+ /**
2
+ * Unzips an array of arrays.
3
+ *
4
+ * If the array is `null` or `undefined`, returns an empty array.
5
+ *
6
+ * @template T
7
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
8
+ * where each inner array contains elements to be unzipped.
9
+ * @returns {T[][]} A new array of unzipped elements.
10
+ *
11
+ * @example
12
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
13
+ * const result = unzipWith(nestedArray);
14
+ * console.log(result); // [[1, 3, 5], [2, 4, 6]]
15
+ *
16
+ * const result2 = unzipWith(null);
17
+ * console.log(result2); // []
18
+ *
19
+ * const result3 = unzipWith();
20
+ * console.log(result3); // []
21
+ */
22
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
23
+ /**
24
+ * Unzips an array of arrays.
25
+ *
26
+ * If the array is `null` or `undefined`, returns an empty array.
27
+ *
28
+ * @template T
29
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
30
+ * where each inner array contains elements to be unzipped.
31
+ * @param {null | undefined} iteratee - A function to transform the unzipped elements.
32
+ * @returns {T[][]} A new array of unzipped elements.
33
+ *
34
+ * @example
35
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
36
+ * const result = unzipWith(nestedArray, null);
37
+ * console.log(result); // [[1, 3, 5], [2, 4, 6]]
38
+ *
39
+ * const result2 = unzipWith(nestedArray);
40
+ * console.log(result2); // [[1, 3, 5], [2, 4, 6]]
41
+ */
42
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee?: null): T[][];
43
+ /**
44
+ * Unzips an array of arrays, applying an `iteratee` function to regrouped elements.
45
+ *
46
+ * If the array is `null` or `undefined`, returns an empty array.
47
+ *
48
+ * @template T, R
49
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
50
+ * where each inner array contains elements to be unzipped.
51
+ * @param {(...args: T[]) => R} iteratee - A function to transform the unzipped elements.
52
+ * @returns {R[]} A new array of unzipped and transformed elements.
53
+ *
54
+ * @example
55
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
56
+ * const result = unzipWith(nestedArray, (a, b) => a + b);
57
+ * console.log(result); // [9, 12]
58
+ */
59
+ declare function unzipWith<T, R>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee: (...args: T[]) => R): R[];
60
+ /**
61
+ * Unzips an array of arrays, applying an `iteratee` function to regrouped elements.
62
+ *
63
+ * If the array is `null` or `undefined`, returns an empty array.
64
+ *
65
+ * @template T
66
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
67
+ * where each inner array contains elements to be unzipped.
68
+ * @param {(...args: any[]) => unknown} iteratee - A function to transform the unzipped elements.
69
+ * @returns {any[]} A new array of unzipped and transformed elements.
70
+ *
71
+ * @example
72
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
73
+ * const result = unzipWith(nestedArray, (a, b) => a + b);
74
+ * console.log(result); // [9, 12]
75
+ */
76
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee: (...args: any[]) => unknown): any[];
77
+
78
+ export { unzipWith };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Unzips an array of arrays.
3
+ *
4
+ * If the array is `null` or `undefined`, returns an empty array.
5
+ *
6
+ * @template T
7
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
8
+ * where each inner array contains elements to be unzipped.
9
+ * @returns {T[][]} A new array of unzipped elements.
10
+ *
11
+ * @example
12
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
13
+ * const result = unzipWith(nestedArray);
14
+ * console.log(result); // [[1, 3, 5], [2, 4, 6]]
15
+ *
16
+ * const result2 = unzipWith(null);
17
+ * console.log(result2); // []
18
+ *
19
+ * const result3 = unzipWith();
20
+ * console.log(result3); // []
21
+ */
22
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
23
+ /**
24
+ * Unzips an array of arrays.
25
+ *
26
+ * If the array is `null` or `undefined`, returns an empty array.
27
+ *
28
+ * @template T
29
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
30
+ * where each inner array contains elements to be unzipped.
31
+ * @param {null | undefined} iteratee - A function to transform the unzipped elements.
32
+ * @returns {T[][]} A new array of unzipped elements.
33
+ *
34
+ * @example
35
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
36
+ * const result = unzipWith(nestedArray, null);
37
+ * console.log(result); // [[1, 3, 5], [2, 4, 6]]
38
+ *
39
+ * const result2 = unzipWith(nestedArray);
40
+ * console.log(result2); // [[1, 3, 5], [2, 4, 6]]
41
+ */
42
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee?: null): T[][];
43
+ /**
44
+ * Unzips an array of arrays, applying an `iteratee` function to regrouped elements.
45
+ *
46
+ * If the array is `null` or `undefined`, returns an empty array.
47
+ *
48
+ * @template T, R
49
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
50
+ * where each inner array contains elements to be unzipped.
51
+ * @param {(...args: T[]) => R} iteratee - A function to transform the unzipped elements.
52
+ * @returns {R[]} A new array of unzipped and transformed elements.
53
+ *
54
+ * @example
55
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
56
+ * const result = unzipWith(nestedArray, (a, b) => a + b);
57
+ * console.log(result); // [9, 12]
58
+ */
59
+ declare function unzipWith<T, R>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee: (...args: T[]) => R): R[];
60
+ /**
61
+ * Unzips an array of arrays, applying an `iteratee` function to regrouped elements.
62
+ *
63
+ * If the array is `null` or `undefined`, returns an empty array.
64
+ *
65
+ * @template T
66
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip. This is an array of arrays,
67
+ * where each inner array contains elements to be unzipped.
68
+ * @param {(...args: any[]) => unknown} iteratee - A function to transform the unzipped elements.
69
+ * @returns {any[]} A new array of unzipped and transformed elements.
70
+ *
71
+ * @example
72
+ * const nestedArray = [[1, 2], [3, 4], [5, 6]];
73
+ * const result = unzipWith(nestedArray, (a, b) => a + b);
74
+ * console.log(result); // [9, 12]
75
+ */
76
+ declare function unzipWith<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined, iteratee: (...args: any[]) => unknown): any[];
77
+
78
+ export { unzipWith };
@@ -0,0 +1,21 @@
1
+ import { unzip } from '../../array/unzip.mjs';
2
+ import { isArray } from '../predicate/isArray.mjs';
3
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
4
+
5
+ function unzipWith(array, iteratee) {
6
+ if (!isArrayLikeObject(array) || !array.length) {
7
+ return [];
8
+ }
9
+ const unziped = isArray(array) ? unzip(array) : unzip(Array.from(array, value => Array.from(value)));
10
+ if (!iteratee) {
11
+ return unziped;
12
+ }
13
+ const result = new Array(unziped.length);
14
+ for (let i = 0; i < unziped.length; i++) {
15
+ const value = unziped[i];
16
+ result[i] = iteratee(...value);
17
+ }
18
+ return result;
19
+ }
20
+
21
+ export { unzipWith };
@@ -6,7 +6,6 @@ export { isSubsetWith } from '../array/isSubsetWith.mjs';
6
6
  export { keyBy } from '../array/keyBy.mjs';
7
7
  export { shuffle } from '../array/shuffle.mjs';
8
8
  export { toFilled } from '../array/toFilled.mjs';
9
- export { unzipWith } from '../array/unzipWith.mjs';
10
9
  export { windowed } from '../array/windowed.mjs';
11
10
  export { xorBy } from '../array/xorBy.mjs';
12
11
  export { xorWith } from '../array/xorWith.mjs';
@@ -125,6 +124,7 @@ export { uniq } from './array/uniq.mjs';
125
124
  export { uniqBy } from './array/uniqBy.mjs';
126
125
  export { uniqWith } from './array/uniqWith.mjs';
127
126
  export { unzip } from './array/unzip.mjs';
127
+ export { unzipWith } from './array/unzipWith.mjs';
128
128
  export { without } from './array/without.mjs';
129
129
  export { xor } from './array/xor.mjs';
130
130
  export { zip } from './array/zip.mjs';
@@ -6,7 +6,6 @@ export { isSubsetWith } from '../array/isSubsetWith.js';
6
6
  export { keyBy } from '../array/keyBy.js';
7
7
  export { shuffle } from '../array/shuffle.js';
8
8
  export { toFilled } from '../array/toFilled.js';
9
- export { unzipWith } from '../array/unzipWith.js';
10
9
  export { windowed } from '../array/windowed.js';
11
10
  export { xorBy } from '../array/xorBy.js';
12
11
  export { xorWith } from '../array/xorWith.js';
@@ -125,6 +124,7 @@ export { uniq } from './array/uniq.js';
125
124
  export { uniqBy } from './array/uniqBy.js';
126
125
  export { uniqWith } from './array/uniqWith.js';
127
126
  export { unzip } from './array/unzip.js';
127
+ export { unzipWith } from './array/unzipWith.js';
128
128
  export { without } from './array/without.js';
129
129
  export { xor } from './array/xor.js';
130
130
  export { zip } from './array/zip.js';
@@ -8,7 +8,6 @@ export { randomInt } from '../math/randomInt.mjs';
8
8
  export { shuffle } from '../array/shuffle.mjs';
9
9
  export { toInteger } from './util/toInteger.mjs';
10
10
  export { toFilled } from '../array/toFilled.mjs';
11
- export { unzipWith } from '../array/unzipWith.mjs';
12
11
  export { windowed } from '../array/windowed.mjs';
13
12
  export { xorBy } from '../array/xorBy.mjs';
14
13
  export { xorWith } from '../array/xorWith.mjs';
@@ -130,6 +129,7 @@ export { uniq } from './array/uniq.mjs';
130
129
  export { uniqBy } from './array/uniqBy.mjs';
131
130
  export { uniqWith } from './array/uniqWith.mjs';
132
131
  export { unzip } from './array/unzip.mjs';
132
+ export { unzipWith } from './array/unzipWith.mjs';
133
133
  export { without } from './array/without.mjs';
134
134
  export { xor } from './array/xor.mjs';
135
135
  export { zip } from './array/zip.mjs';
@@ -6,7 +6,6 @@ export { isSubsetWith } from '../array/isSubsetWith.mjs';
6
6
  export { keyBy } from '../array/keyBy.mjs';
7
7
  export { shuffle } from '../array/shuffle.mjs';
8
8
  export { toFilled } from '../array/toFilled.mjs';
9
- export { unzipWith } from '../array/unzipWith.mjs';
10
9
  export { windowed } from '../array/windowed.mjs';
11
10
  export { xorBy } from '../array/xorBy.mjs';
12
11
  export { xorWith } from '../array/xorWith.mjs';
@@ -125,6 +124,7 @@ export { uniq } from './array/uniq.mjs';
125
124
  export { uniqBy } from './array/uniqBy.mjs';
126
125
  export { uniqWith } from './array/uniqWith.mjs';
127
126
  export { unzip } from './array/unzip.mjs';
127
+ export { unzipWith } from './array/unzipWith.mjs';
128
128
  export { without } from './array/without.mjs';
129
129
  export { xor } from './array/xor.mjs';
130
130
  export { zip } from './array/zip.mjs';
@@ -6,7 +6,6 @@ export { isSubsetWith } from '../array/isSubsetWith.js';
6
6
  export { keyBy } from '../array/keyBy.js';
7
7
  export { shuffle } from '../array/shuffle.js';
8
8
  export { toFilled } from '../array/toFilled.js';
9
- export { unzipWith } from '../array/unzipWith.js';
10
9
  export { windowed } from '../array/windowed.js';
11
10
  export { xorBy } from '../array/xorBy.js';
12
11
  export { xorWith } from '../array/xorWith.js';
@@ -125,6 +124,7 @@ export { uniq } from './array/uniq.js';
125
124
  export { uniqBy } from './array/uniqBy.js';
126
125
  export { uniqWith } from './array/uniqWith.js';
127
126
  export { unzip } from './array/unzip.js';
127
+ export { unzipWith } from './array/unzipWith.js';
128
128
  export { without } from './array/without.js';
129
129
  export { xor } from './array/xor.js';
130
130
  export { zip } from './array/zip.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const zip$1 = require('../_chunk/zip-CzDcYv.js');
5
+ const zip$1 = require('../_chunk/zip-DDfXXG.js');
6
6
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
7
7
  const AbortError = require('../_chunk/AbortError-Cg4ZQ1.js');
8
8
  const error_index = require('../error/index.js');
@@ -1851,6 +1851,22 @@ function unzip(array) {
1851
1851
  return zip$1.unzip(array);
1852
1852
  }
1853
1853
 
1854
+ function unzipWith(array, iteratee) {
1855
+ if (!isArrayLikeObject(array) || !array.length) {
1856
+ return [];
1857
+ }
1858
+ const unziped = toSnakeCaseKeys.isArray(array) ? zip$1.unzip(array) : zip$1.unzip(Array.from(array, value => Array.from(value)));
1859
+ if (!iteratee) {
1860
+ return unziped;
1861
+ }
1862
+ const result = new Array(unziped.length);
1863
+ for (let i = 0; i < unziped.length; i++) {
1864
+ const value = unziped[i];
1865
+ result[i] = iteratee(...value);
1866
+ }
1867
+ return result;
1868
+ }
1869
+
1854
1870
  function without(array, ...values) {
1855
1871
  if (!isArrayLikeObject(array)) {
1856
1872
  return [];
@@ -4303,7 +4319,7 @@ const compat = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4303
4319
  uniqueId,
4304
4320
  unset,
4305
4321
  unzip,
4306
- unzipWith: zip$1.unzipWith,
4322
+ unzipWith,
4307
4323
  update,
4308
4324
  updateWith,
4309
4325
  upperCase,
@@ -4342,7 +4358,6 @@ exports.toFilled = zip$1.toFilled;
4342
4358
  exports.toFinite = zip$1.toFinite;
4343
4359
  exports.toInteger = zip$1.toInteger;
4344
4360
  exports.toNumber = zip$1.toNumber;
4345
- exports.unzipWith = zip$1.unzipWith;
4346
4361
  exports.windowed = zip$1.windowed;
4347
4362
  exports.xorBy = zip$1.xorBy;
4348
4363
  exports.xorWith = zip$1.xorWith;
@@ -4636,6 +4651,7 @@ exports.uniqWith = uniqWith;
4636
4651
  exports.uniqueId = uniqueId;
4637
4652
  exports.unset = unset;
4638
4653
  exports.unzip = unzip;
4654
+ exports.unzipWith = unzipWith;
4639
4655
  exports.update = update;
4640
4656
  exports.updateWith = updateWith;
4641
4657
  exports.upperCase = upperCase;
@@ -8,7 +8,6 @@ export { randomInt } from '../math/randomInt.mjs';
8
8
  export { shuffle } from '../array/shuffle.mjs';
9
9
  export { toInteger } from './util/toInteger.mjs';
10
10
  export { toFilled } from '../array/toFilled.mjs';
11
- export { unzipWith } from '../array/unzipWith.mjs';
12
11
  export { windowed } from '../array/windowed.mjs';
13
12
  export { xorBy } from '../array/xorBy.mjs';
14
13
  export { xorWith } from '../array/xorWith.mjs';
@@ -130,6 +129,7 @@ export { uniq } from './array/uniq.mjs';
130
129
  export { uniqBy } from './array/uniqBy.mjs';
131
130
  export { uniqWith } from './array/uniqWith.mjs';
132
131
  export { unzip } from './array/unzip.mjs';
132
+ export { unzipWith } from './array/unzipWith.mjs';
133
133
  export { without } from './array/without.mjs';
134
134
  export { xor } from './array/xor.mjs';
135
135
  export { zip } from './array/zip.mjs';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const array_index = require('./array/index.js');
6
- const zip = require('./_chunk/zip-CzDcYv.js');
6
+ const zip = require('./_chunk/zip-DDfXXG.js');
7
7
  const AbortError = require('./_chunk/AbortError-Cg4ZQ1.js');
8
8
  const error_index = require('./error/index.js');
9
9
  const unary = require('./_chunk/unary-EIEhcF.js');
@@ -37,6 +37,7 @@ exports.sortBy = array_index.sortBy;
37
37
  exports.takeRightWhile = array_index.takeRightWhile;
38
38
  exports.takeWhile = array_index.takeWhile;
39
39
  exports.union = array_index.union;
40
+ exports.unzipWith = array_index.unzipWith;
40
41
  exports.xor = array_index.xor;
41
42
  exports.zipObject = array_index.zipObject;
42
43
  exports.zipWith = array_index.zipWith;
@@ -81,7 +82,6 @@ exports.uniq = zip.uniq;
81
82
  exports.uniqBy = zip.uniqBy;
82
83
  exports.uniqWith = zip.uniqWith;
83
84
  exports.unzip = zip.unzip;
84
- exports.unzipWith = zip.unzipWith;
85
85
  exports.windowed = zip.windowed;
86
86
  exports.without = zip.without;
87
87
  exports.xorBy = zip.xorBy;
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.36.0-dev.1230+f149e1fb",
4
+ "version": "1.36.0-dev.1232+159939b7",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {