@sapphire/iterator-utilities 1.0.3-next.cd7e6b59 → 1.0.3-next.ec73e32c
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.
- package/dist/cjs/lib/contains.cjs +1 -2
- package/dist/cjs/lib/contains.cjs.map +1 -1
- package/dist/cjs/lib/drop.cjs +3 -6
- package/dist/cjs/lib/drop.cjs.map +1 -1
- package/dist/cjs/lib/dropLast.cjs +1 -2
- package/dist/cjs/lib/dropLast.cjs.map +1 -1
- package/dist/cjs/lib/every.cjs +1 -2
- package/dist/cjs/lib/every.cjs.map +1 -1
- package/dist/cjs/lib/filter.cjs +1 -2
- package/dist/cjs/lib/filter.cjs.map +1 -1
- package/dist/cjs/lib/max.cjs +1 -2
- package/dist/cjs/lib/max.cjs.map +1 -1
- package/dist/cjs/lib/min.cjs +1 -2
- package/dist/cjs/lib/min.cjs.map +1 -1
- package/dist/cjs/lib/reduce.cjs +1 -2
- package/dist/cjs/lib/reduce.cjs.map +1 -1
- package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs +3 -6
- package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs.map +1 -1
- package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs +3 -6
- package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs.map +1 -1
- package/dist/cjs/lib/slice.cjs +1 -2
- package/dist/cjs/lib/slice.cjs.map +1 -1
- package/dist/cjs/lib/take.cjs +1 -2
- package/dist/cjs/lib/take.cjs.map +1 -1
- package/dist/cjs/lib/takeLast.cjs +2 -4
- package/dist/cjs/lib/takeLast.cjs.map +1 -1
- package/dist/cjs/lib/tee.cjs +1 -2
- package/dist/cjs/lib/tee.cjs.map +1 -1
- package/dist/cjs/lib/unzip.cjs +1 -2
- package/dist/cjs/lib/unzip.cjs.map +1 -1
- package/dist/cjs/lib/zip.cjs +1 -2
- package/dist/cjs/lib/zip.cjs.map +1 -1
- package/dist/esm/{chunk-G5GHKT7C.mjs → chunk-PAWJFY3S.mjs} +1 -1
- package/dist/esm/lib/append.mjs +1 -1
- package/dist/esm/lib/at.mjs +1 -1
- package/dist/esm/lib/average.mjs +1 -1
- package/dist/esm/lib/chain.mjs +1 -1
- package/dist/esm/lib/chunk.mjs +1 -1
- package/dist/esm/lib/compact.mjs +1 -1
- package/dist/esm/lib/compress.mjs +1 -1
- package/dist/esm/lib/contains.mjs +2 -3
- package/dist/esm/lib/contains.mjs.map +1 -1
- package/dist/esm/lib/count.mjs +1 -1
- package/dist/esm/lib/cycle.mjs +1 -1
- package/dist/esm/lib/difference.mjs +1 -1
- package/dist/esm/lib/drop.mjs +4 -7
- package/dist/esm/lib/drop.mjs.map +1 -1
- package/dist/esm/lib/dropLast.mjs +2 -3
- package/dist/esm/lib/dropLast.mjs.map +1 -1
- package/dist/esm/lib/dropWhile.mjs +1 -1
- package/dist/esm/lib/empty.mjs +1 -1
- package/dist/esm/lib/enumerate.mjs +1 -1
- package/dist/esm/lib/every.mjs +2 -3
- package/dist/esm/lib/every.mjs.map +1 -1
- package/dist/esm/lib/filter.mjs +2 -3
- package/dist/esm/lib/filter.mjs.map +1 -1
- package/dist/esm/lib/find.mjs +1 -1
- package/dist/esm/lib/findIndex.mjs +1 -1
- package/dist/esm/lib/first.mjs +1 -1
- package/dist/esm/lib/flat.mjs +1 -1
- package/dist/esm/lib/flatMap.mjs +1 -1
- package/dist/esm/lib/forEach.mjs +1 -1
- package/dist/esm/lib/from.mjs +1 -1
- package/dist/esm/lib/indexOf.mjs +1 -1
- package/dist/esm/lib/intersect.mjs +1 -1
- package/dist/esm/lib/isEmpty.mjs +1 -1
- package/dist/esm/lib/last.mjs +1 -1
- package/dist/esm/lib/map.mjs +1 -1
- package/dist/esm/lib/max.mjs +2 -3
- package/dist/esm/lib/max.mjs.map +1 -1
- package/dist/esm/lib/min.mjs +2 -3
- package/dist/esm/lib/min.mjs.map +1 -1
- package/dist/esm/lib/partition.mjs +1 -1
- package/dist/esm/lib/peekable.mjs +1 -1
- package/dist/esm/lib/prepend.mjs +1 -1
- package/dist/esm/lib/product.mjs +1 -1
- package/dist/esm/lib/range.mjs +1 -1
- package/dist/esm/lib/reduce.mjs +2 -3
- package/dist/esm/lib/reduce.mjs.map +1 -1
- package/dist/esm/lib/repeat.mjs +1 -1
- package/dist/esm/lib/reverse.mjs +1 -1
- package/dist/esm/lib/shared/_assertFunction.mjs +1 -1
- package/dist/esm/lib/shared/_assertNotNegative.mjs +1 -1
- package/dist/esm/lib/shared/_assertPositive.mjs +1 -1
- package/dist/esm/lib/shared/_makeIterableIterator.mjs +1 -1
- package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs +4 -7
- package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs.map +1 -1
- package/dist/esm/lib/shared/_toIntegerOrThrow.mjs +4 -7
- package/dist/esm/lib/shared/_toIntegerOrThrow.mjs.map +1 -1
- package/dist/esm/lib/shared/_toNumberOrThrow.mjs +1 -1
- package/dist/esm/lib/slice.mjs +2 -3
- package/dist/esm/lib/slice.mjs.map +1 -1
- package/dist/esm/lib/some.mjs +1 -1
- package/dist/esm/lib/sorted.mjs +1 -1
- package/dist/esm/lib/starMap.mjs +1 -1
- package/dist/esm/lib/sum.mjs +1 -1
- package/dist/esm/lib/take.mjs +2 -3
- package/dist/esm/lib/take.mjs.map +1 -1
- package/dist/esm/lib/takeLast.mjs +3 -5
- package/dist/esm/lib/takeLast.mjs.map +1 -1
- package/dist/esm/lib/tee.mjs +2 -3
- package/dist/esm/lib/tee.mjs.map +1 -1
- package/dist/esm/lib/toArray.mjs +1 -1
- package/dist/esm/lib/toIterableIterator.mjs +1 -1
- package/dist/esm/lib/union.mjs +1 -1
- package/dist/esm/lib/unique.mjs +1 -1
- package/dist/esm/lib/unzip.mjs +2 -3
- package/dist/esm/lib/unzip.mjs.map +1 -1
- package/dist/esm/lib/zip.mjs +2 -3
- package/dist/esm/lib/zip.mjs.map +1 -1
- package/dist/iife/index.global.js +23 -46
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +5 -5
- /package/dist/esm/{chunk-G5GHKT7C.mjs.map → chunk-PAWJFY3S.mjs.map} +0 -0
package/dist/esm/lib/unzip.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
3
3
|
|
|
4
4
|
function unzip(iterable) {
|
|
@@ -12,8 +12,7 @@ function unzip(iterable) {
|
|
|
12
12
|
}
|
|
13
13
|
const size = firstResult.value.length;
|
|
14
14
|
const results = [];
|
|
15
|
-
for (let i = 0; i < size; i++)
|
|
16
|
-
results.push([firstResult.value[i]]);
|
|
15
|
+
for (let i = 0; i < size; i++) results.push([firstResult.value[i]]);
|
|
17
16
|
for (const entries of resolvedIterable) {
|
|
18
17
|
if (!Array.isArray(entries)) {
|
|
19
18
|
throw new Error("Cannot unzip an iterable that does not yield an array");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/unzip.ts"],"names":[],"mappings":";;;;;AACA,SAAS,0BAA0B;AA0B5B,SAAS,MAAgD,UAAuE;AACtI,QAAM,mBAAmB,mBAAmB,QAAQ;AACpD,QAAM,cAAc,iBAAiB,KAAK;AAC1C,MAAI,YAAY,MAAM;AACrB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EACjD;AAEA,MAAI,CAAC,MAAM,QAAQ,YAAY,KAAK,GAAG;AACtC,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACxE;AAEA,QAAM,OAAO,YAAY,MAAM;AAC/B,QAAM,UAAU,CAAC;AACjB,WAAS,IAAI,GAAG,IAAI,MAAM
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/unzip.ts"],"names":[],"mappings":";;;;;AACA,SAAS,0BAA0B;AA0B5B,SAAS,MAAgD,UAAuE;AACtI,QAAM,mBAAmB,mBAAmB,QAAQ;AACpD,QAAM,cAAc,iBAAiB,KAAK;AAC1C,MAAI,YAAY,MAAM;AACrB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EACjD;AAEA,MAAI,CAAC,MAAM,QAAQ,YAAY,KAAK,GAAG;AACtC,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACxE;AAEA,QAAM,OAAO,YAAY,MAAM;AAC/B,QAAM,UAAU,CAAC;AACjB,WAAS,IAAI,GAAG,IAAI,MAAM,IAAK,SAAQ,KAAK,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC;AAClE,aAAW,WAAW,kBAAkB;AACvC,QAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC5B,YAAM,IAAI,MAAM,uDAAuD;AAAA,IACxE;AAEA,QAAI,QAAQ,WAAW,MAAM;AAC5B,YAAM,IAAI,MAAM,gEAAgE;AAAA,IACjF;AAEA,aAAS,IAAI,GAAG,IAAI,MAAM,KAAK;AAC9B,cAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC3B;AAAA,EACD;AAEA,SAAO;AACR;AA7BgB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an array for each element of the input iterable, transposing the input iterable. The opposite of {@linkcode zip}.\n *\n * @param iterable An iterable to unzip.\n * @returns An array of iterables that yield the values of the original iterable.\n *\n * @example\n * ```typescript\n * import { unzip } from '@sapphire/iterator-utilities';\n *\n * const iterable = [[1, 'a'], [2, 'b'], [3, 'c']];\n * const [numbers, letters] = unzip(iterable);\n *\n * console.log(numbers);\n * // Output: [1, 2, 3]\n *\n * console.log(letters);\n * // Output: ['a', 'b', 'c']\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterable.\n */\nexport function unzip<const ElementType extends readonly any[]>(iterable: IterableResolvable<ElementType>): UnzipIterable<ElementType> {\n\tconst resolvedIterable = toIterableIterator(iterable);\n\tconst firstResult = resolvedIterable.next();\n\tif (firstResult.done) {\n\t\tthrow new Error('Cannot unzip an empty iterable');\n\t}\n\n\tif (!Array.isArray(firstResult.value)) {\n\t\tthrow new Error('Cannot unzip an iterable that does not yield an array');\n\t}\n\n\tconst size = firstResult.value.length;\n\tconst results = [] as ElementType[][];\n\tfor (let i = 0; i < size; i++) results.push([firstResult.value[i]]);\n\tfor (const entries of resolvedIterable) {\n\t\tif (!Array.isArray(entries)) {\n\t\t\tthrow new Error('Cannot unzip an iterable that does not yield an array');\n\t\t}\n\n\t\tif (entries.length !== size) {\n\t\t\tthrow new Error('Cannot unzip an iterable that yields arrays of different sizes');\n\t\t}\n\n\t\tfor (let i = 0; i < size; i++) {\n\t\t\tresults[i].push(entries[i]);\n\t\t}\n\t}\n\n\treturn results as UnzipIterable<ElementType>;\n}\n\nexport type UnzipIterable<ElementType extends readonly any[]> = {\n\t-readonly [P in keyof ElementType]: ElementType[P][];\n};\n"]}
|
package/dist/esm/lib/zip.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { from } from './from.mjs';
|
|
3
3
|
|
|
4
4
|
function* zip(...iterables) {
|
|
@@ -7,8 +7,7 @@ function* zip(...iterables) {
|
|
|
7
7
|
const results = [];
|
|
8
8
|
for (const resolvedIterable of resolvedIterables) {
|
|
9
9
|
const result = resolvedIterable.next();
|
|
10
|
-
if (result.done)
|
|
11
|
-
return;
|
|
10
|
+
if (result.done) return;
|
|
12
11
|
results.push(result.value);
|
|
13
12
|
}
|
|
14
13
|
yield results;
|
package/dist/esm/lib/zip.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/zip.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAAqC;AAwBvC,UAAU,OAAmE,WAA+C;AAClI,QAAM,oBAAoB,UAAU,IAAI,CAAC,aAAa,KAAK,QAAQ,CAAC;AACpE,SAAO,MAAM;AACZ,UAAM,UAAU,CAAC;AACjB,eAAW,oBAAoB,mBAAmB;AACjD,YAAM,SAAS,iBAAiB,KAAK;AACrC,UAAI,OAAO;
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/zip.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,YAAqC;AAwBvC,UAAU,OAAmE,WAA+C;AAClI,QAAM,oBAAoB,UAAU,IAAI,CAAC,aAAa,KAAK,QAAQ,CAAC;AACpE,SAAO,MAAM;AACZ,UAAM,UAAU,CAAC;AACjB,eAAW,oBAAoB,mBAAmB;AACjD,YAAM,SAAS,iBAAiB,KAAK;AACrC,UAAI,OAAO,KAAM;AAEjB,cAAQ,KAAK,OAAO,KAAK;AAAA,IAC1B;AAEA,UAAM;AAAA,EACP;AACD;AAbiB","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Creates an iterable with the elements of the input iterables zipped together. The opposite of {@linkcode unzip}.\n *\n * @param iterables The iterables to zip together.\n * @returns A new iterable that yields the next value of each iterable in the list.\n *\n * @example\n * ```typescript\n * import { zip } from '@sapphire/iterator-utilities';\n *\n * const iterable1 = [1, 2, 3];\n * const iterable2 = ['a', 'b', 'c'];\n * const iterable3 = [true, false, true];\n *\n * console.log(zip(iterable1, iterable2, iterable3));\n * // Output: [\n * // \t[1, 'a', true],\n * // \t[2, 'b', false],\n * // \t[3, 'c', true]\n * // ]\n * ```\n */\nexport function* zip<const Iterables extends readonly IterableResolvable<any>[]>(...iterables: Iterables): ZipIterators<Iterables> {\n\tconst resolvedIterables = iterables.map((iterable) => from(iterable));\n\twhile (true) {\n\t\tconst results = [] as any[];\n\t\tfor (const resolvedIterable of resolvedIterables) {\n\t\t\tconst result = resolvedIterable.next();\n\t\t\tif (result.done) return;\n\n\t\t\tresults.push(result.value);\n\t\t}\n\n\t\tyield results as any;\n\t}\n}\n\nexport type ZipIterators<Iterators extends readonly IterableResolvable<any>[]> = IterableIterator<{\n\t-readonly [P in keyof Iterators]: Iterators[P] extends IterableResolvable<infer T> ? T : never;\n}>;\n"]}
|
|
@@ -100,12 +100,9 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
100
100
|
// src/lib/shared/_toIntegerOrInfinityOrThrow.ts
|
|
101
101
|
function toIntegerOrInfinityOrThrow(value) {
|
|
102
102
|
const number = toNumberOrThrow(value);
|
|
103
|
-
if (Number.isNaN(number) || number === 0)
|
|
104
|
-
|
|
105
|
-
if (number === Number.
|
|
106
|
-
return Number.POSITIVE_INFINITY;
|
|
107
|
-
if (number === Number.NEGATIVE_INFINITY)
|
|
108
|
-
return Number.NEGATIVE_INFINITY;
|
|
103
|
+
if (Number.isNaN(number) || number === 0) return 0;
|
|
104
|
+
if (number === Number.POSITIVE_INFINITY) return Number.POSITIVE_INFINITY;
|
|
105
|
+
if (number === Number.NEGATIVE_INFINITY) return Number.NEGATIVE_INFINITY;
|
|
109
106
|
return Math.trunc(number);
|
|
110
107
|
}
|
|
111
108
|
__name(toIntegerOrInfinityOrThrow, "toIntegerOrInfinityOrThrow");
|
|
@@ -114,13 +111,10 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
114
111
|
function drop(iterable, count2) {
|
|
115
112
|
count2 = assertNotNegative(toIntegerOrInfinityOrThrow(count2), count2);
|
|
116
113
|
const resolvedIterable = toIterableIterator(iterable);
|
|
117
|
-
if (count2 === 0)
|
|
118
|
-
|
|
119
|
-
if (count2 === Number.POSITIVE_INFINITY)
|
|
120
|
-
return empty();
|
|
114
|
+
if (count2 === 0) return resolvedIterable;
|
|
115
|
+
if (count2 === Number.POSITIVE_INFINITY) return empty();
|
|
121
116
|
for (let i = 0; i < count2; i++) {
|
|
122
|
-
if (resolvedIterable.next().done)
|
|
123
|
-
break;
|
|
117
|
+
if (resolvedIterable.next().done) break;
|
|
124
118
|
}
|
|
125
119
|
return resolvedIterable;
|
|
126
120
|
}
|
|
@@ -182,12 +176,9 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
182
176
|
// src/lib/shared/_toIntegerOrThrow.ts
|
|
183
177
|
function toIntegerOrThrow(value) {
|
|
184
178
|
const number = toNumberOrThrow(value);
|
|
185
|
-
if (Number.isNaN(number) || number === 0)
|
|
186
|
-
|
|
187
|
-
if (number === Number.
|
|
188
|
-
throw new RangeError("+Infinity cannot be represented as an integer");
|
|
189
|
-
if (number === Number.NEGATIVE_INFINITY)
|
|
190
|
-
throw new RangeError("-Infinity cannot be represented as an integer");
|
|
179
|
+
if (Number.isNaN(number) || number === 0) return 0;
|
|
180
|
+
if (number === Number.POSITIVE_INFINITY) throw new RangeError("+Infinity cannot be represented as an integer");
|
|
181
|
+
if (number === Number.NEGATIVE_INFINITY) throw new RangeError("-Infinity cannot be represented as an integer");
|
|
191
182
|
return Math.trunc(number);
|
|
192
183
|
}
|
|
193
184
|
__name(toIntegerOrThrow, "toIntegerOrThrow");
|
|
@@ -214,8 +205,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
214
205
|
callbackFn = assertFunction(callbackFn);
|
|
215
206
|
let index = 0;
|
|
216
207
|
for (const value of toIterableIterator(iterable)) {
|
|
217
|
-
if (callbackFn(value, index++))
|
|
218
|
-
yield value;
|
|
208
|
+
if (callbackFn(value, index++)) yield value;
|
|
219
209
|
}
|
|
220
210
|
}
|
|
221
211
|
__name(filter, "filter");
|
|
@@ -244,8 +234,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
244
234
|
// src/lib/contains.ts
|
|
245
235
|
function contains(iterable, value) {
|
|
246
236
|
for (const element of toIterableIterator(iterable)) {
|
|
247
|
-
if (element === value)
|
|
248
|
-
return true;
|
|
237
|
+
if (element === value) return true;
|
|
249
238
|
}
|
|
250
239
|
return false;
|
|
251
240
|
}
|
|
@@ -287,8 +276,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
287
276
|
// src/lib/take.ts
|
|
288
277
|
function take(iterable, count2) {
|
|
289
278
|
count2 = assertNotNegative(toIntegerOrInfinityOrThrow(count2), count2);
|
|
290
|
-
if (count2 === 0)
|
|
291
|
-
return empty();
|
|
279
|
+
if (count2 === 0) return empty();
|
|
292
280
|
let i = 0;
|
|
293
281
|
const resolvedIterable = from(iterable);
|
|
294
282
|
return makeIterableIterator(
|
|
@@ -307,8 +295,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
307
295
|
function dropLast(iterable, count2) {
|
|
308
296
|
count2 = assertNotNegative(toIntegerOrInfinityOrThrow(count2), count2);
|
|
309
297
|
const array = toArray(iterable);
|
|
310
|
-
if (array.length <= count2)
|
|
311
|
-
return empty();
|
|
298
|
+
if (array.length <= count2) return empty();
|
|
312
299
|
return take(array.values(), array.length - count2);
|
|
313
300
|
}
|
|
314
301
|
__name(dropLast, "dropLast");
|
|
@@ -339,8 +326,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
339
326
|
callbackFn = assertFunction(callbackFn);
|
|
340
327
|
let index = 0;
|
|
341
328
|
for (const value of toIterableIterator(iterable)) {
|
|
342
|
-
if (!callbackFn(value, index++))
|
|
343
|
-
return false;
|
|
329
|
+
if (!callbackFn(value, index++)) return false;
|
|
344
330
|
}
|
|
345
331
|
return true;
|
|
346
332
|
}
|
|
@@ -434,8 +420,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
434
420
|
function max(iterable) {
|
|
435
421
|
let max2 = null;
|
|
436
422
|
for (const value of map(iterable, toNumberOrThrow)) {
|
|
437
|
-
if (max2 === null || value > max2)
|
|
438
|
-
max2 = value;
|
|
423
|
+
if (max2 === null || value > max2) max2 = value;
|
|
439
424
|
}
|
|
440
425
|
return max2;
|
|
441
426
|
}
|
|
@@ -445,8 +430,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
445
430
|
function min(iterable) {
|
|
446
431
|
let min2 = null;
|
|
447
432
|
for (const value of map(iterable, toNumberOrThrow)) {
|
|
448
|
-
if (min2 === null || value < min2)
|
|
449
|
-
min2 = value;
|
|
433
|
+
if (min2 === null || value < min2) min2 = value;
|
|
450
434
|
}
|
|
451
435
|
return min2;
|
|
452
436
|
}
|
|
@@ -548,8 +532,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
548
532
|
const resolvedIterable = toIterableIterator(iterable);
|
|
549
533
|
if (arguments.length < 3) {
|
|
550
534
|
const firstValue = resolvedIterable.next();
|
|
551
|
-
if (firstValue.done)
|
|
552
|
-
throw new TypeError("Reduce of empty iterator with no initial value");
|
|
535
|
+
if (firstValue.done) throw new TypeError("Reduce of empty iterator with no initial value");
|
|
553
536
|
index = 1;
|
|
554
537
|
accumulator = firstValue.value;
|
|
555
538
|
} else {
|
|
@@ -588,10 +571,8 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
588
571
|
// src/lib/takeLast.ts
|
|
589
572
|
function takeLast(iterable, count2) {
|
|
590
573
|
count2 = assertNotNegative(toIntegerOrInfinityOrThrow(count2), count2);
|
|
591
|
-
if (count2 === 0)
|
|
592
|
-
|
|
593
|
-
if (count2 === Number.POSITIVE_INFINITY)
|
|
594
|
-
return toIterableIterator(iterable);
|
|
574
|
+
if (count2 === 0) return empty();
|
|
575
|
+
if (count2 === Number.POSITIVE_INFINITY) return toIterableIterator(iterable);
|
|
595
576
|
const array = toArray(iterable);
|
|
596
577
|
let i = Math.max(0, array.length - count2);
|
|
597
578
|
return makeIterableIterator(() => {
|
|
@@ -628,8 +609,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
628
609
|
}
|
|
629
610
|
return take(takeLast(iterable, -start), end - start);
|
|
630
611
|
}
|
|
631
|
-
if (start >= end)
|
|
632
|
-
return empty();
|
|
612
|
+
if (start >= end) return empty();
|
|
633
613
|
return end === Number.POSITIVE_INFINITY ? drop(iterable, start) : take(drop(iterable, start), end - start);
|
|
634
614
|
}
|
|
635
615
|
__name(slice, "slice");
|
|
@@ -675,8 +655,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
675
655
|
// src/lib/tee.ts
|
|
676
656
|
function tee(iterable, count2) {
|
|
677
657
|
count2 = assertNotNegative(toIntegerOrThrow(count2), count2);
|
|
678
|
-
if (count2 === 0)
|
|
679
|
-
return [];
|
|
658
|
+
if (count2 === 0) return [];
|
|
680
659
|
const entries = [];
|
|
681
660
|
const indexes = toArray(repeat(0, count2));
|
|
682
661
|
const resolvedIterable = from(iterable);
|
|
@@ -730,8 +709,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
730
709
|
}
|
|
731
710
|
const size = firstResult.value.length;
|
|
732
711
|
const results = [];
|
|
733
|
-
for (let i = 0; i < size; i++)
|
|
734
|
-
results.push([firstResult.value[i]]);
|
|
712
|
+
for (let i = 0; i < size; i++) results.push([firstResult.value[i]]);
|
|
735
713
|
for (const entries of resolvedIterable) {
|
|
736
714
|
if (!Array.isArray(entries)) {
|
|
737
715
|
throw new Error("Cannot unzip an iterable that does not yield an array");
|
|
@@ -754,8 +732,7 @@ var SapphireIteratorUtilities = (function (exports) {
|
|
|
754
732
|
const results = [];
|
|
755
733
|
for (const resolvedIterable of resolvedIterables) {
|
|
756
734
|
const result = resolvedIterable.next();
|
|
757
|
-
if (result.done)
|
|
758
|
-
return;
|
|
735
|
+
if (result.done) return;
|
|
759
736
|
results.push(result.value);
|
|
760
737
|
}
|
|
761
738
|
yield results;
|