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

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,134 @@
1
+ /**
2
+ * Combines multiple arrays into a single array of tuples.
3
+ *
4
+ * This function takes multiple arrays and returns a new array where each element is a tuple
5
+ * containing the corresponding elements from the input arrays. If the input arrays are of
6
+ * different lengths, the resulting array will have the length of the longest input array,
7
+ * with undefined values for missing elements.
8
+ *
9
+ * @template T
10
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
11
+ * @returns {Array<[T | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
12
+ *
13
+ * @example
14
+ * const arr1 = [1, 2, 3];
15
+ * const result = zip(arr1);
16
+ * // result will be [[1], [2], [3]]
17
+ */
18
+ declare function zip<T>(arr1: ArrayLike<T>): Array<[T | undefined]>;
19
+ /**
20
+ * Combines multiple arrays into a single array of tuples.
21
+ *
22
+ * This function takes multiple arrays and returns a new array where each element is a tuple
23
+ * containing the corresponding elements from the input arrays. If the input arrays are of
24
+ * different lengths, the resulting array will have the length of the longest input array,
25
+ * with undefined values for missing elements.
26
+ *
27
+ * @template T, U
28
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
29
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
30
+ * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
31
+ *
32
+ * @example
33
+ * const arr1 = [1, 2, 3];
34
+ * const arr2 = ['a', 'b', 'c'];
35
+ * const result = zip(arr1, arr2);
36
+ * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>;
39
+ /**
40
+ * Combines multiple arrays into a single array of tuples.
41
+ *
42
+ * This function takes multiple arrays and returns a new array where each element is a tuple
43
+ * containing the corresponding elements from the input arrays. If the input arrays are of
44
+ * different lengths, the resulting array will have the length of the longest input array,
45
+ * with undefined values for missing elements.
46
+ *
47
+ * @template T, U, V
48
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
49
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
50
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
51
+ * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
52
+ *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
56
+ * const arr3 = [true, false];
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
59
+ */
60
+ declare function zip<T, U, V>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>): Array<[T | undefined, U | undefined, V | undefined]>;
61
+ /**
62
+ * Combines multiple arrays into a single array of tuples.
63
+ *
64
+ * This function takes multiple arrays and returns a new array where each element is a tuple
65
+ * containing the corresponding elements from the input arrays. If the input arrays are of
66
+ * different lengths, the resulting array will have the length of the longest input array,
67
+ * with undefined values for missing elements.
68
+ *
69
+ * @template T, U, V, W
70
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
71
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
72
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
73
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
75
+ *
76
+ * @example
77
+ * const arr1 = [1, 2, 3];
78
+ * const arr2 = ['a', 'b', 'c'];
79
+ * const arr3 = [true, false];
80
+ * const arr4 = [null, null, null];
81
+ * const result = zip(arr1, arr2, arr3, arr4);
82
+ * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
83
+ */
84
+ declare function zip<T, U, V, W>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>;
85
+ /**
86
+ * Combines multiple arrays into a single array of tuples.
87
+ *
88
+ * This function takes multiple arrays and returns a new array where each element is a tuple
89
+ * containing the corresponding elements from the input arrays. If the input arrays are of
90
+ * different lengths, the resulting array will have the length of the longest input array,
91
+ * with undefined values for missing elements.
92
+ *
93
+ * @template T, U, V, W
94
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
95
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
96
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
97
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
98
+ * @param {ArrayLike<X>} arr5 - The fifth array to zip.
99
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
100
+ *
101
+ * @example
102
+ * const arr1 = [1, 2, 3];
103
+ * const arr2 = ['a', 'b', 'c'];
104
+ * const arr3 = [true, false];
105
+ * const arr4 = [null, null, null];
106
+ * const arr5 = [undefined, undefined, undefined];
107
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
108
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
109
+ */
110
+ declare function zip<T, U, V, W, X>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>, arr5: ArrayLike<X>): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>;
111
+ /**
112
+ * Combines multiple arrays into a single array of tuples.
113
+ *
114
+ * This function takes multiple arrays and returns a new array where each element is a tuple
115
+ * containing the corresponding elements from the input arrays. If the input arrays are of
116
+ * different lengths, the resulting array will have the length of the longest input array,
117
+ * with undefined values for missing elements.
118
+ *
119
+ * @template T
120
+ * @param {Array<ArrayLike<any> | null | undefined>} arrays - The arrays to zip.
121
+ * @returns {Array<Array<T | undefined>>} A new array of tuples containing the corresponding elements from the input arrays.
122
+ *
123
+ * @example
124
+ * const arr1 = [1, 2, 3];
125
+ * const arr2 = ['a', 'b', 'c'];
126
+ * const arr3 = [true, false];
127
+ * const arr4 = [null, null, null];
128
+ * const arr5 = [undefined, undefined, undefined];
129
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
130
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
131
+ */
132
+ declare function zip<T>(...arrays: Array<ArrayLike<any> | null | undefined>): Array<Array<T | undefined>>;
133
+
134
+ export { zip };
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Combines multiple arrays into a single array of tuples.
3
+ *
4
+ * This function takes multiple arrays and returns a new array where each element is a tuple
5
+ * containing the corresponding elements from the input arrays. If the input arrays are of
6
+ * different lengths, the resulting array will have the length of the longest input array,
7
+ * with undefined values for missing elements.
8
+ *
9
+ * @template T
10
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
11
+ * @returns {Array<[T | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
12
+ *
13
+ * @example
14
+ * const arr1 = [1, 2, 3];
15
+ * const result = zip(arr1);
16
+ * // result will be [[1], [2], [3]]
17
+ */
18
+ declare function zip<T>(arr1: ArrayLike<T>): Array<[T | undefined]>;
19
+ /**
20
+ * Combines multiple arrays into a single array of tuples.
21
+ *
22
+ * This function takes multiple arrays and returns a new array where each element is a tuple
23
+ * containing the corresponding elements from the input arrays. If the input arrays are of
24
+ * different lengths, the resulting array will have the length of the longest input array,
25
+ * with undefined values for missing elements.
26
+ *
27
+ * @template T, U
28
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
29
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
30
+ * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
31
+ *
32
+ * @example
33
+ * const arr1 = [1, 2, 3];
34
+ * const arr2 = ['a', 'b', 'c'];
35
+ * const result = zip(arr1, arr2);
36
+ * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>;
39
+ /**
40
+ * Combines multiple arrays into a single array of tuples.
41
+ *
42
+ * This function takes multiple arrays and returns a new array where each element is a tuple
43
+ * containing the corresponding elements from the input arrays. If the input arrays are of
44
+ * different lengths, the resulting array will have the length of the longest input array,
45
+ * with undefined values for missing elements.
46
+ *
47
+ * @template T, U, V
48
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
49
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
50
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
51
+ * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
52
+ *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
56
+ * const arr3 = [true, false];
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
59
+ */
60
+ declare function zip<T, U, V>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>): Array<[T | undefined, U | undefined, V | undefined]>;
61
+ /**
62
+ * Combines multiple arrays into a single array of tuples.
63
+ *
64
+ * This function takes multiple arrays and returns a new array where each element is a tuple
65
+ * containing the corresponding elements from the input arrays. If the input arrays are of
66
+ * different lengths, the resulting array will have the length of the longest input array,
67
+ * with undefined values for missing elements.
68
+ *
69
+ * @template T, U, V, W
70
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
71
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
72
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
73
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
75
+ *
76
+ * @example
77
+ * const arr1 = [1, 2, 3];
78
+ * const arr2 = ['a', 'b', 'c'];
79
+ * const arr3 = [true, false];
80
+ * const arr4 = [null, null, null];
81
+ * const result = zip(arr1, arr2, arr3, arr4);
82
+ * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
83
+ */
84
+ declare function zip<T, U, V, W>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>;
85
+ /**
86
+ * Combines multiple arrays into a single array of tuples.
87
+ *
88
+ * This function takes multiple arrays and returns a new array where each element is a tuple
89
+ * containing the corresponding elements from the input arrays. If the input arrays are of
90
+ * different lengths, the resulting array will have the length of the longest input array,
91
+ * with undefined values for missing elements.
92
+ *
93
+ * @template T, U, V, W
94
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
95
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
96
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
97
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
98
+ * @param {ArrayLike<X>} arr5 - The fifth array to zip.
99
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
100
+ *
101
+ * @example
102
+ * const arr1 = [1, 2, 3];
103
+ * const arr2 = ['a', 'b', 'c'];
104
+ * const arr3 = [true, false];
105
+ * const arr4 = [null, null, null];
106
+ * const arr5 = [undefined, undefined, undefined];
107
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
108
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
109
+ */
110
+ declare function zip<T, U, V, W, X>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>, arr5: ArrayLike<X>): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>;
111
+ /**
112
+ * Combines multiple arrays into a single array of tuples.
113
+ *
114
+ * This function takes multiple arrays and returns a new array where each element is a tuple
115
+ * containing the corresponding elements from the input arrays. If the input arrays are of
116
+ * different lengths, the resulting array will have the length of the longest input array,
117
+ * with undefined values for missing elements.
118
+ *
119
+ * @template T
120
+ * @param {Array<ArrayLike<any> | null | undefined>} arrays - The arrays to zip.
121
+ * @returns {Array<Array<T | undefined>>} A new array of tuples containing the corresponding elements from the input arrays.
122
+ *
123
+ * @example
124
+ * const arr1 = [1, 2, 3];
125
+ * const arr2 = ['a', 'b', 'c'];
126
+ * const arr3 = [true, false];
127
+ * const arr4 = [null, null, null];
128
+ * const arr5 = [undefined, undefined, undefined];
129
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
130
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
131
+ */
132
+ declare function zip<T>(...arrays: Array<ArrayLike<any> | null | undefined>): Array<Array<T | undefined>>;
133
+
134
+ export { zip };
@@ -0,0 +1,11 @@
1
+ import { zip as zip$1 } from '../../array/zip.mjs';
2
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
3
+
4
+ function zip(...arrays) {
5
+ if (!arrays.length) {
6
+ return [];
7
+ }
8
+ return zip$1(...arrays.filter(group => isArrayLikeObject(group)));
9
+ }
10
+
11
+ export { zip };
@@ -27,7 +27,6 @@ export { unzipWith } from '../array/unzipWith.mjs';
27
27
  export { xor } from '../array/xor.mjs';
28
28
  export { xorBy } from '../array/xorBy.mjs';
29
29
  export { xorWith } from '../array/xorWith.mjs';
30
- export { zip } from '../array/zip.mjs';
31
30
  export { zipObject } from '../array/zipObject.mjs';
32
31
  export { zipWith } from '../array/zipWith.mjs';
33
32
  export { AbortError } from '../error/AbortError.mjs';
@@ -116,6 +115,7 @@ export { takeRight } from './array/takeRight.mjs';
116
115
  export { uniq } from './array/uniq.mjs';
117
116
  export { unzip } from './array/unzip.mjs';
118
117
  export { without } from './array/without.mjs';
118
+ export { zip } from './array/zip.mjs';
119
119
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
120
120
  export { ary } from './function/ary.mjs';
121
121
  export { attempt } from './function/attempt.mjs';
@@ -27,7 +27,6 @@ export { unzipWith } from '../array/unzipWith.js';
27
27
  export { xor } from '../array/xor.js';
28
28
  export { xorBy } from '../array/xorBy.js';
29
29
  export { xorWith } from '../array/xorWith.js';
30
- export { zip } from '../array/zip.js';
31
30
  export { zipObject } from '../array/zipObject.js';
32
31
  export { zipWith } from '../array/zipWith.js';
33
32
  export { AbortError } from '../error/AbortError.js';
@@ -116,6 +115,7 @@ export { takeRight } from './array/takeRight.js';
116
115
  export { uniq } from './array/uniq.js';
117
116
  export { unzip } from './array/unzip.js';
118
117
  export { without } from './array/without.js';
118
+ export { zip } from './array/zip.js';
119
119
  export { zipObjectDeep } from './array/zipObjectDeep.js';
120
120
  export { ary } from './function/ary.js';
121
121
  export { attempt } from './function/attempt.js';
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('../_chunk/zipWith-Dkv3D1.js');
5
+ const zipWith = require('../_chunk/zipWith-Dx_q4f.js');
6
6
  const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const unary = require('../_chunk/unary-CcTNuC.js');
8
8
  const noop = require('../_chunk/noop-2IwLUk.js');
9
- const sumBy = require('../_chunk/sumBy-CRE6-A.js');
9
+ const sumBy = require('../_chunk/sumBy-wtGD37.js');
10
10
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
11
11
  const toMerged = require('../_chunk/toMerged-wNz52b.js');
12
12
  const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
@@ -1174,6 +1174,13 @@ function without(array, ...values) {
1174
1174
  return zipWith.without(Array.from(array), ...values);
1175
1175
  }
1176
1176
 
1177
+ function zip(...arrays) {
1178
+ if (!arrays.length) {
1179
+ return [];
1180
+ }
1181
+ return zipWith.zip(...arrays.filter(group => isArrayLikeObject(group)));
1182
+ }
1183
+
1177
1184
  function set(obj, path, value) {
1178
1185
  const resolvedPath = Array.isArray(path) ? path : typeof path === 'string' ? toPath(path) : [path];
1179
1186
  let current = obj;
@@ -2475,7 +2482,6 @@ exports.unzipWith = zipWith.unzipWith;
2475
2482
  exports.xor = zipWith.xor;
2476
2483
  exports.xorBy = zipWith.xorBy;
2477
2484
  exports.xorWith = zipWith.xorWith;
2478
- exports.zip = zipWith.zip;
2479
2485
  exports.zipObject = zipWith.zipObject;
2480
2486
  exports.zipWith = zipWith.zipWith;
2481
2487
  exports.AbortError = promise_index.AbortError;
@@ -2672,4 +2678,5 @@ exports.unset = unset;
2672
2678
  exports.unzip = unzip;
2673
2679
  exports.upperCase = upperCase;
2674
2680
  exports.without = without;
2681
+ exports.zip = zip;
2675
2682
  exports.zipObjectDeep = zipObjectDeep;
@@ -27,7 +27,6 @@ export { unzipWith } from '../array/unzipWith.mjs';
27
27
  export { xor } from '../array/xor.mjs';
28
28
  export { xorBy } from '../array/xorBy.mjs';
29
29
  export { xorWith } from '../array/xorWith.mjs';
30
- export { zip } from '../array/zip.mjs';
31
30
  export { zipObject } from '../array/zipObject.mjs';
32
31
  export { zipWith } from '../array/zipWith.mjs';
33
32
  export { AbortError } from '../error/AbortError.mjs';
@@ -118,6 +117,7 @@ export { takeRight } from './array/takeRight.mjs';
118
117
  export { uniq } from './array/uniq.mjs';
119
118
  export { unzip } from './array/unzip.mjs';
120
119
  export { without } from './array/without.mjs';
120
+ export { zip } from './array/zip.mjs';
121
121
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
122
122
  export { ary } from './function/ary.mjs';
123
123
  export { attempt } from './function/attempt.mjs';
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zipWith = require('./_chunk/zipWith-Dkv3D1.js');
5
+ const zipWith = require('./_chunk/zipWith-Dx_q4f.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-CcTNuC.js');
9
9
  const function_index = require('./function/index.js');
10
10
  const noop = require('./_chunk/noop-2IwLUk.js');
11
- const sumBy = require('./_chunk/sumBy-CRE6-A.js');
11
+ const sumBy = require('./_chunk/sumBy-wtGD37.js');
12
12
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
13
13
  const math_index = require('./math/index.js');
14
14
  const toMerged = require('./_chunk/toMerged-wNz52b.js');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const sumBy = require('../_chunk/sumBy-CRE6-A.js');
5
+ const sumBy = require('../_chunk/sumBy-wtGD37.js');
6
6
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
7
7
 
8
8
  function round(value, precision = 0) {
@@ -1,11 +1,8 @@
1
- function range(start, end, step) {
1
+ function range(start, end, step = 1) {
2
2
  if (end == null) {
3
3
  end = start;
4
4
  start = 0;
5
5
  }
6
- if (step == null) {
7
- step = 1;
8
- }
9
6
  if (!Number.isInteger(step) || step === 0) {
10
7
  throw new Error(`The step value must be a non-zero integer.`);
11
8
  }
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.847+5b9e9656",
4
+ "version": "1.26.1-dev.850+7dbf58a9",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {