@sapphire/iterator-utilities 1.0.3-next.cd7e6b59 → 1.0.3-next.db356eb0
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/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lib/append.cjs +1 -1
- package/dist/cjs/lib/append.cjs.map +1 -1
- package/dist/cjs/lib/at.cjs +1 -1
- package/dist/cjs/lib/at.cjs.map +1 -1
- package/dist/cjs/lib/average.cjs +1 -1
- package/dist/cjs/lib/average.cjs.map +1 -1
- package/dist/cjs/lib/chain.cjs +1 -1
- package/dist/cjs/lib/chain.cjs.map +1 -1
- package/dist/cjs/lib/chunk.cjs +1 -1
- package/dist/cjs/lib/chunk.cjs.map +1 -1
- package/dist/cjs/lib/compact.cjs +1 -1
- package/dist/cjs/lib/compact.cjs.map +1 -1
- package/dist/cjs/lib/compress.cjs +1 -1
- package/dist/cjs/lib/compress.cjs.map +1 -1
- package/dist/cjs/lib/contains.cjs +2 -3
- package/dist/cjs/lib/contains.cjs.map +1 -1
- package/dist/cjs/lib/count.cjs +1 -1
- package/dist/cjs/lib/count.cjs.map +1 -1
- package/dist/cjs/lib/cycle.cjs +1 -1
- package/dist/cjs/lib/cycle.cjs.map +1 -1
- package/dist/cjs/lib/difference.cjs +1 -1
- package/dist/cjs/lib/difference.cjs.map +1 -1
- package/dist/cjs/lib/drop.cjs +4 -7
- package/dist/cjs/lib/drop.cjs.map +1 -1
- package/dist/cjs/lib/dropLast.cjs +2 -3
- package/dist/cjs/lib/dropLast.cjs.map +1 -1
- package/dist/cjs/lib/dropWhile.cjs +1 -1
- package/dist/cjs/lib/dropWhile.cjs.map +1 -1
- package/dist/cjs/lib/empty.cjs +1 -1
- package/dist/cjs/lib/empty.cjs.map +1 -1
- package/dist/cjs/lib/enumerate.cjs +1 -1
- package/dist/cjs/lib/enumerate.cjs.map +1 -1
- package/dist/cjs/lib/every.cjs +2 -3
- package/dist/cjs/lib/every.cjs.map +1 -1
- package/dist/cjs/lib/filter.cjs +2 -3
- package/dist/cjs/lib/filter.cjs.map +1 -1
- package/dist/cjs/lib/find.cjs +1 -1
- package/dist/cjs/lib/find.cjs.map +1 -1
- package/dist/cjs/lib/findIndex.cjs +1 -1
- package/dist/cjs/lib/findIndex.cjs.map +1 -1
- package/dist/cjs/lib/first.cjs +1 -1
- package/dist/cjs/lib/first.cjs.map +1 -1
- package/dist/cjs/lib/flat.cjs +1 -1
- package/dist/cjs/lib/flat.cjs.map +1 -1
- package/dist/cjs/lib/flatMap.cjs +1 -1
- package/dist/cjs/lib/flatMap.cjs.map +1 -1
- package/dist/cjs/lib/forEach.cjs +1 -1
- package/dist/cjs/lib/forEach.cjs.map +1 -1
- package/dist/cjs/lib/from.cjs +1 -1
- package/dist/cjs/lib/from.cjs.map +1 -1
- package/dist/cjs/lib/indexOf.cjs +1 -1
- package/dist/cjs/lib/indexOf.cjs.map +1 -1
- package/dist/cjs/lib/intersect.cjs +1 -1
- package/dist/cjs/lib/intersect.cjs.map +1 -1
- package/dist/cjs/lib/isEmpty.cjs +1 -1
- package/dist/cjs/lib/isEmpty.cjs.map +1 -1
- package/dist/cjs/lib/last.cjs +1 -1
- package/dist/cjs/lib/last.cjs.map +1 -1
- package/dist/cjs/lib/map.cjs +1 -1
- package/dist/cjs/lib/map.cjs.map +1 -1
- package/dist/cjs/lib/max.cjs +2 -3
- package/dist/cjs/lib/max.cjs.map +1 -1
- package/dist/cjs/lib/min.cjs +2 -3
- package/dist/cjs/lib/min.cjs.map +1 -1
- package/dist/cjs/lib/partition.cjs +1 -1
- package/dist/cjs/lib/partition.cjs.map +1 -1
- package/dist/cjs/lib/peekable.cjs +1 -1
- package/dist/cjs/lib/peekable.cjs.map +1 -1
- package/dist/cjs/lib/prepend.cjs +1 -1
- package/dist/cjs/lib/prepend.cjs.map +1 -1
- package/dist/cjs/lib/product.cjs +1 -1
- package/dist/cjs/lib/product.cjs.map +1 -1
- package/dist/cjs/lib/range.cjs +1 -1
- package/dist/cjs/lib/range.cjs.map +1 -1
- package/dist/cjs/lib/reduce.cjs +2 -3
- package/dist/cjs/lib/reduce.cjs.map +1 -1
- package/dist/cjs/lib/repeat.cjs +1 -1
- package/dist/cjs/lib/repeat.cjs.map +1 -1
- package/dist/cjs/lib/reverse.cjs +1 -1
- package/dist/cjs/lib/reverse.cjs.map +1 -1
- package/dist/cjs/lib/shared/_assertFunction.cjs +1 -1
- package/dist/cjs/lib/shared/_assertFunction.cjs.map +1 -1
- package/dist/cjs/lib/shared/_assertNotNegative.cjs +1 -1
- package/dist/cjs/lib/shared/_assertNotNegative.cjs.map +1 -1
- package/dist/cjs/lib/shared/_assertPositive.cjs +1 -1
- package/dist/cjs/lib/shared/_assertPositive.cjs.map +1 -1
- package/dist/cjs/lib/shared/_makeIterableIterator.cjs +1 -1
- package/dist/cjs/lib/shared/_makeIterableIterator.cjs.map +1 -1
- package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs +4 -7
- package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs.map +1 -1
- package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs +4 -7
- package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs.map +1 -1
- package/dist/cjs/lib/shared/_toNumberOrThrow.cjs +1 -1
- package/dist/cjs/lib/shared/_toNumberOrThrow.cjs.map +1 -1
- package/dist/cjs/lib/slice.cjs +2 -3
- package/dist/cjs/lib/slice.cjs.map +1 -1
- package/dist/cjs/lib/some.cjs +1 -1
- package/dist/cjs/lib/some.cjs.map +1 -1
- package/dist/cjs/lib/sorted.cjs +1 -1
- package/dist/cjs/lib/sorted.cjs.map +1 -1
- package/dist/cjs/lib/starMap.cjs +1 -1
- package/dist/cjs/lib/starMap.cjs.map +1 -1
- package/dist/cjs/lib/sum.cjs +1 -1
- package/dist/cjs/lib/sum.cjs.map +1 -1
- package/dist/cjs/lib/take.cjs +2 -3
- package/dist/cjs/lib/take.cjs.map +1 -1
- package/dist/cjs/lib/takeLast.cjs +3 -5
- package/dist/cjs/lib/takeLast.cjs.map +1 -1
- package/dist/cjs/lib/tee.cjs +2 -3
- package/dist/cjs/lib/tee.cjs.map +1 -1
- package/dist/cjs/lib/toArray.cjs +1 -1
- package/dist/cjs/lib/toArray.cjs.map +1 -1
- package/dist/cjs/lib/toIterableIterator.cjs +1 -1
- package/dist/cjs/lib/toIterableIterator.cjs.map +1 -1
- package/dist/cjs/lib/union.cjs +1 -1
- package/dist/cjs/lib/union.cjs.map +1 -1
- package/dist/cjs/lib/unique.cjs +1 -1
- package/dist/cjs/lib/unique.cjs.map +1 -1
- package/dist/cjs/lib/unzip.cjs +2 -3
- package/dist/cjs/lib/unzip.cjs.map +1 -1
- package/dist/cjs/lib/zip.cjs +2 -3
- package/dist/cjs/lib/zip.cjs.map +1 -1
- package/dist/esm/{chunk-G5GHKT7C.mjs → chunk-PAWJFY3S.mjs} +2 -2
- package/dist/esm/chunk-PAWJFY3S.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/append.mjs +2 -2
- package/dist/esm/lib/append.mjs.map +1 -1
- package/dist/esm/lib/at.mjs +2 -2
- package/dist/esm/lib/at.mjs.map +1 -1
- package/dist/esm/lib/average.mjs +2 -2
- package/dist/esm/lib/average.mjs.map +1 -1
- package/dist/esm/lib/chain.mjs +2 -2
- package/dist/esm/lib/chain.mjs.map +1 -1
- package/dist/esm/lib/chunk.mjs +2 -2
- package/dist/esm/lib/chunk.mjs.map +1 -1
- package/dist/esm/lib/compact.mjs +2 -2
- package/dist/esm/lib/compact.mjs.map +1 -1
- package/dist/esm/lib/compress.mjs +2 -2
- package/dist/esm/lib/compress.mjs.map +1 -1
- package/dist/esm/lib/contains.mjs +3 -4
- package/dist/esm/lib/contains.mjs.map +1 -1
- package/dist/esm/lib/count.mjs +2 -2
- package/dist/esm/lib/count.mjs.map +1 -1
- package/dist/esm/lib/cycle.mjs +2 -2
- package/dist/esm/lib/cycle.mjs.map +1 -1
- package/dist/esm/lib/difference.mjs +2 -2
- package/dist/esm/lib/difference.mjs.map +1 -1
- package/dist/esm/lib/drop.mjs +5 -8
- package/dist/esm/lib/drop.mjs.map +1 -1
- package/dist/esm/lib/dropLast.mjs +3 -4
- package/dist/esm/lib/dropLast.mjs.map +1 -1
- package/dist/esm/lib/dropWhile.mjs +2 -2
- package/dist/esm/lib/dropWhile.mjs.map +1 -1
- package/dist/esm/lib/empty.mjs +2 -2
- package/dist/esm/lib/empty.mjs.map +1 -1
- package/dist/esm/lib/enumerate.mjs +2 -2
- package/dist/esm/lib/enumerate.mjs.map +1 -1
- package/dist/esm/lib/every.mjs +3 -4
- package/dist/esm/lib/every.mjs.map +1 -1
- package/dist/esm/lib/filter.mjs +3 -4
- package/dist/esm/lib/filter.mjs.map +1 -1
- package/dist/esm/lib/find.mjs +2 -2
- package/dist/esm/lib/find.mjs.map +1 -1
- package/dist/esm/lib/findIndex.mjs +2 -2
- package/dist/esm/lib/findIndex.mjs.map +1 -1
- package/dist/esm/lib/first.mjs +2 -2
- package/dist/esm/lib/first.mjs.map +1 -1
- package/dist/esm/lib/flat.mjs +2 -2
- package/dist/esm/lib/flat.mjs.map +1 -1
- package/dist/esm/lib/flatMap.mjs +2 -2
- package/dist/esm/lib/flatMap.mjs.map +1 -1
- package/dist/esm/lib/forEach.mjs +2 -2
- package/dist/esm/lib/forEach.mjs.map +1 -1
- package/dist/esm/lib/from.mjs +2 -2
- package/dist/esm/lib/from.mjs.map +1 -1
- package/dist/esm/lib/indexOf.mjs +2 -2
- package/dist/esm/lib/indexOf.mjs.map +1 -1
- package/dist/esm/lib/intersect.mjs +2 -2
- package/dist/esm/lib/intersect.mjs.map +1 -1
- package/dist/esm/lib/isEmpty.mjs +2 -2
- package/dist/esm/lib/isEmpty.mjs.map +1 -1
- package/dist/esm/lib/last.mjs +2 -2
- package/dist/esm/lib/last.mjs.map +1 -1
- package/dist/esm/lib/map.mjs +2 -2
- package/dist/esm/lib/map.mjs.map +1 -1
- package/dist/esm/lib/max.mjs +3 -4
- package/dist/esm/lib/max.mjs.map +1 -1
- package/dist/esm/lib/min.mjs +3 -4
- package/dist/esm/lib/min.mjs.map +1 -1
- package/dist/esm/lib/partition.mjs +2 -2
- package/dist/esm/lib/partition.mjs.map +1 -1
- package/dist/esm/lib/peekable.mjs +2 -2
- package/dist/esm/lib/peekable.mjs.map +1 -1
- package/dist/esm/lib/prepend.mjs +2 -2
- package/dist/esm/lib/prepend.mjs.map +1 -1
- package/dist/esm/lib/product.mjs +2 -2
- package/dist/esm/lib/product.mjs.map +1 -1
- package/dist/esm/lib/range.mjs +2 -2
- package/dist/esm/lib/range.mjs.map +1 -1
- package/dist/esm/lib/reduce.mjs +3 -4
- package/dist/esm/lib/reduce.mjs.map +1 -1
- package/dist/esm/lib/repeat.mjs +2 -2
- package/dist/esm/lib/repeat.mjs.map +1 -1
- package/dist/esm/lib/reverse.mjs +2 -2
- package/dist/esm/lib/reverse.mjs.map +1 -1
- package/dist/esm/lib/shared/_assertFunction.mjs +2 -2
- package/dist/esm/lib/shared/_assertFunction.mjs.map +1 -1
- package/dist/esm/lib/shared/_assertNotNegative.mjs +2 -2
- package/dist/esm/lib/shared/_assertNotNegative.mjs.map +1 -1
- package/dist/esm/lib/shared/_assertPositive.mjs +2 -2
- package/dist/esm/lib/shared/_assertPositive.mjs.map +1 -1
- package/dist/esm/lib/shared/_makeIterableIterator.mjs +2 -2
- package/dist/esm/lib/shared/_makeIterableIterator.mjs.map +1 -1
- package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs +5 -8
- package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs.map +1 -1
- package/dist/esm/lib/shared/_toIntegerOrThrow.mjs +5 -8
- package/dist/esm/lib/shared/_toIntegerOrThrow.mjs.map +1 -1
- package/dist/esm/lib/shared/_toNumberOrThrow.mjs +2 -2
- package/dist/esm/lib/shared/_toNumberOrThrow.mjs.map +1 -1
- package/dist/esm/lib/slice.mjs +3 -4
- package/dist/esm/lib/slice.mjs.map +1 -1
- package/dist/esm/lib/some.mjs +2 -2
- package/dist/esm/lib/some.mjs.map +1 -1
- package/dist/esm/lib/sorted.mjs +2 -2
- package/dist/esm/lib/sorted.mjs.map +1 -1
- package/dist/esm/lib/starMap.mjs +2 -2
- package/dist/esm/lib/starMap.mjs.map +1 -1
- package/dist/esm/lib/sum.mjs +2 -2
- package/dist/esm/lib/sum.mjs.map +1 -1
- package/dist/esm/lib/take.mjs +3 -4
- package/dist/esm/lib/take.mjs.map +1 -1
- package/dist/esm/lib/takeLast.mjs +4 -6
- package/dist/esm/lib/takeLast.mjs.map +1 -1
- package/dist/esm/lib/tee.mjs +3 -4
- package/dist/esm/lib/tee.mjs.map +1 -1
- package/dist/esm/lib/toArray.mjs +2 -2
- package/dist/esm/lib/toArray.mjs.map +1 -1
- package/dist/esm/lib/toIterableIterator.mjs +2 -2
- package/dist/esm/lib/toIterableIterator.mjs.map +1 -1
- package/dist/esm/lib/union.mjs +2 -2
- package/dist/esm/lib/union.mjs.map +1 -1
- package/dist/esm/lib/unique.mjs +2 -2
- package/dist/esm/lib/unique.mjs.map +1 -1
- package/dist/esm/lib/unzip.mjs +3 -4
- package/dist/esm/lib/unzip.mjs.map +1 -1
- package/dist/esm/lib/zip.mjs +3 -4
- package/dist/esm/lib/zip.mjs.map +1 -1
- package/dist/iife/index.global.js +24 -47
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +9 -9
- package/dist/esm/chunk-G5GHKT7C.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/count.ts"],"names":["count"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/count.ts"],"names":["count"],"mappings":";;;AAqBO,SAAS,MAAyB,QAAmD,EAAA;AAC3F,EAAA,IAAIA,MAAQ,GAAA,CAAA,CAAA;AACZ,EAAM,MAAA,gBAAA,GAAmB,KAAK,QAAQ,CAAA,CAAA;AACtC,EAAA,OAAO,CAAC,gBAAA,CAAiB,IAAK,EAAA,CAAE,IAAM,EAAA;AACrC,IAAAA,MAAAA,EAAAA,CAAAA;AAAA,GACD;AAEA,EAAOA,OAAAA,MAAAA,CAAAA;AACR,CAAA;AARgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"count.mjs","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Consumes the iterable and returns the number of elements.\n *\n * @param iterable An iterator that contains elements to be counted.\n * @returns The number of elements in the input iterator.\n *\n * @example\n * ```typescript\n * import { count } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(count(iterable));\n * // Output: 5\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function count<const ElementType>(iterable: IterableResolvable<ElementType>): number {\n\tlet count = 0;\n\tconst resolvedIterable = from(iterable);\n\twhile (!resolvedIterable.next().done) {\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n"]}
|
package/dist/esm/lib/cycle.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* cycle(iterable) {
|
|
@@ -16,5 +16,5 @@ function* cycle(iterable) {
|
|
|
16
16
|
__name(cycle, "cycle");
|
|
17
17
|
|
|
18
18
|
export { cycle };
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=cycle.mjs.map
|
|
20
20
|
//# sourceMappingURL=cycle.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/cycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/cycle.ts"],"names":[],"mappings":";;;AAmBO,UAAU,MAAyB,QAA0E,EAAA;AACnH,EAAA,MAAM,UAAU,EAAC,CAAA;AACjB,EAAW,KAAA,MAAA,OAAA,IAAW,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACnD,IAAM,MAAA,OAAA,CAAA;AACN,IAAA,OAAA,CAAQ,KAAK,OAAO,CAAA,CAAA;AAAA,GACrB;AAEA,EAAO,OAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AAC1B,IAAA,KAAA,MAAW,WAAW,OAAS,EAAA;AAC9B,MAAM,MAAA,OAAA,CAAA;AAAA,KACP;AAAA,GACD;AACD,CAAA;AAZiB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"cycle.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an infinite iterable by cycling through the elements of the input iterable.\n *\n * @param iterable An iterator to cycle over.\n *\n * @example\n * ```typescript\n * import { cycle } from '@sapphire/iterator-utilities';\n *\n * const iterable = cycle([1, 2, 3]);\n * for (const element of iterable) {\n * \tconsole.log(element);\n * \t// Output: 1, 2, 3, 1, 2, 3, 1, 2, 3, ...\n * }\n * ```\n */\nexport function* cycle<const ElementType>(iterable: IterableResolvable<ElementType>): IterableIterator<ElementType> {\n\tconst results = [] as ElementType[];\n\tfor (const element of toIterableIterator(iterable)) {\n\t\tyield element;\n\t\tresults.push(element);\n\t}\n\n\twhile (results.length > 0) {\n\t\tfor (const element of results) {\n\t\t\tyield element;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { filter } from './filter.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -9,5 +9,5 @@ function difference(first, second) {
|
|
|
9
9
|
__name(difference, "difference");
|
|
10
10
|
|
|
11
11
|
export { difference, difference as except, difference as omit };
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=difference.mjs.map
|
|
13
13
|
//# sourceMappingURL=difference.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/difference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/difference.ts"],"names":[],"mappings":";;;;AAwBO,SAAS,UAAA,CACf,OACA,MACgC,EAAA;AAChC,EAAA,MAAM,GAAM,GAAA,IAAI,GAAI,CAAA,kBAAA,CAAmB,MAAM,CAAC,CAAA,CAAA;AAC9C,EAAO,OAAA,MAAA,CAAO,OAAO,CAAC,KAAA,KAAU,CAAC,GAAI,CAAA,GAAA,CAAI,KAAK,CAAC,CAAA,CAAA;AAChD,CAAA;AANgB,MAAA,CAAA,UAAA,EAAA,YAAA,CAAA","file":"difference.mjs","sourcesContent":["import { filter } from './filter';\nimport type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable with the elements of the first iterable that are not in the second iterable.\n *\n * @param first An iterator to return elements from.\n * @param second An iterator that contains elements to exclude from the result.\n *\n * @example\n * ```typescript\n * import { difference } from '@sapphire/iterator-utilities';\n *\n * const first = [1, 2, 3, 4, 5];\n * const second = [3, 4, 5, 6, 7];\n * console.log([...difference(first, second)]);\n * // Output: [1, 2]\n * ```\n *\n * @remarks\n *\n * This function consumes the entire `second` iterator to build the set of elements to exclude from `first`.\n */\nexport function difference<const ElementType>(\n\tfirst: IterableResolvable<ElementType>,\n\tsecond: IterableResolvable<ElementType>\n): IterableIterator<ElementType> {\n\tconst set = new Set(toIterableIterator(second));\n\treturn filter(first, (value) => !set.has(value));\n}\n\nexport { difference as except, difference as omit };\n"]}
|
package/dist/esm/lib/drop.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { empty } from './empty.mjs';
|
|
3
3
|
import { assertNotNegative } from './shared/_assertNotNegative.mjs';
|
|
4
4
|
import { toIntegerOrInfinityOrThrow } from './shared/_toIntegerOrInfinityOrThrow.mjs';
|
|
@@ -7,18 +7,15 @@ import { toIterableIterator } from './toIterableIterator.mjs';
|
|
|
7
7
|
function drop(iterable, count) {
|
|
8
8
|
count = assertNotNegative(toIntegerOrInfinityOrThrow(count), count);
|
|
9
9
|
const resolvedIterable = toIterableIterator(iterable);
|
|
10
|
-
if (count === 0)
|
|
11
|
-
|
|
12
|
-
if (count === Number.POSITIVE_INFINITY)
|
|
13
|
-
return empty();
|
|
10
|
+
if (count === 0) return resolvedIterable;
|
|
11
|
+
if (count === Number.POSITIVE_INFINITY) return empty();
|
|
14
12
|
for (let i = 0; i < count; i++) {
|
|
15
|
-
if (resolvedIterable.next().done)
|
|
16
|
-
break;
|
|
13
|
+
if (resolvedIterable.next().done) break;
|
|
17
14
|
}
|
|
18
15
|
return resolvedIterable;
|
|
19
16
|
}
|
|
20
17
|
__name(drop, "drop");
|
|
21
18
|
|
|
22
19
|
export { drop, drop as skip };
|
|
23
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=drop.mjs.map
|
|
24
21
|
//# sourceMappingURL=drop.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/drop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/drop.ts"],"names":[],"mappings":";;;;;;AAsBO,SAAS,IAAA,CAAwB,UAA2C,KAA8C,EAAA;AAChI,EAAA,KAAA,GAAQ,iBAAkB,CAAA,0BAAA,CAA2B,KAAK,CAAA,EAAG,KAAK,CAAA,CAAA;AAClE,EAAM,MAAA,gBAAA,GAAmB,mBAAmB,QAAQ,CAAA,CAAA;AAGpD,EAAI,IAAA,KAAA,KAAU,GAAU,OAAA,gBAAA,CAAA;AAExB,EAAA,IAAI,KAAU,KAAA,MAAA,CAAO,iBAAmB,EAAA,OAAO,KAAM,EAAA,CAAA;AAErD,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,KAAA,EAAO,CAAK,EAAA,EAAA;AAC/B,IAAI,IAAA,gBAAA,CAAiB,IAAK,EAAA,CAAE,IAAM,EAAA,MAAA;AAAA,GACnC;AAEA,EAAO,OAAA,gBAAA,CAAA;AACR,CAAA;AAdgB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA","file":"drop.mjs","sourcesContent":["import { empty } from './empty';\nimport type { IterableResolvable } from './from';\nimport { assertNotNegative } from './shared/_assertNotNegative';\nimport { toIntegerOrInfinityOrThrow } from './shared/_toIntegerOrInfinityOrThrow';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Advances the iterable by `count` elements from the iterable.\n *\n * @param iterable An iterator to drop values from.\n * @param count The number of elements to drop from the start of the iteration.\n * @returns An iterator that contains the elements of the provided iterator, except for the first `count` elements.\n *\n * @example\n * ```typescript\n * import { drop } from '@sapphire/iterator-utilities';\n *\n * const iterable = drop(iterator, 2);\n * console.log([...iterable]);\n * // Output: [3, 4, 5]\n * ```\n */\nexport function drop<const ElementType>(iterable: IterableResolvable<ElementType>, count: number): IterableIterator<ElementType> {\n\tcount = assertNotNegative(toIntegerOrInfinityOrThrow(count), count);\n\tconst resolvedIterable = toIterableIterator(iterable);\n\n\t// If the count is 0, return the original iterable:\n\tif (count === 0) return resolvedIterable;\n\t// If the count is infinite, return an empty iterable:\n\tif (count === Number.POSITIVE_INFINITY) return empty();\n\n\tfor (let i = 0; i < count; i++) {\n\t\tif (resolvedIterable.next().done) break;\n\t}\n\n\treturn resolvedIterable;\n}\n\nexport { drop as skip };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { empty } from './empty.mjs';
|
|
3
3
|
import { assertNotNegative } from './shared/_assertNotNegative.mjs';
|
|
4
4
|
import { toIntegerOrInfinityOrThrow } from './shared/_toIntegerOrInfinityOrThrow.mjs';
|
|
@@ -8,12 +8,11 @@ import { toArray } from './toArray.mjs';
|
|
|
8
8
|
function dropLast(iterable, count) {
|
|
9
9
|
count = assertNotNegative(toIntegerOrInfinityOrThrow(count), count);
|
|
10
10
|
const array = toArray(iterable);
|
|
11
|
-
if (array.length <= count)
|
|
12
|
-
return empty();
|
|
11
|
+
if (array.length <= count) return empty();
|
|
13
12
|
return take(array.values(), array.length - count);
|
|
14
13
|
}
|
|
15
14
|
__name(dropLast, "dropLast");
|
|
16
15
|
|
|
17
16
|
export { dropLast, dropLast as skipLast };
|
|
18
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=dropLast.mjs.map
|
|
19
18
|
//# sourceMappingURL=dropLast.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/dropLast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/dropLast.ts"],"names":[],"mappings":";;;;;;;AA2BO,SAAS,QAAA,CAA4B,UAA2C,KAA8C,EAAA;AACpI,EAAA,KAAA,GAAQ,iBAAkB,CAAA,0BAAA,CAA2B,KAAK,CAAA,EAAG,KAAK,CAAA,CAAA;AAClE,EAAM,MAAA,KAAA,GAAQ,QAAQ,QAAQ,CAAA,CAAA;AAC9B,EAAA,IAAI,KAAM,CAAA,MAAA,IAAU,KAAO,EAAA,OAAO,KAAM,EAAA,CAAA;AACxC,EAAA,OAAO,KAAK,KAAM,CAAA,MAAA,EAAU,EAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AACjD,CAAA;AALgB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"dropLast.mjs","sourcesContent":["import { empty } from './empty';\nimport type { IterableResolvable } from './from';\nimport { assertNotNegative } from './shared/_assertNotNegative';\nimport { toIntegerOrInfinityOrThrow } from './shared/_toIntegerOrInfinityOrThrow';\nimport { take } from './take';\nimport { toArray } from './toArray';\n\n/**\n * Consumes the iterable, creating a new iterator without the last `count` elements from the iterable.\n *\n * @param iterable An iterator to drop values from.\n * @param count The number of values to drop from the end of the iterator.\n * @returns An iterator that contains the elements of the provided iterator, except for the last `count` elements.\n *\n * @example\n * ```typescript\n * import { dropLast } from '@sapphire/iterator-utilities';\n *\n * const iterable = dropLast([1, 2, 3, 4, 5], 2);\n * console.log([...iterable]);\n * // Output: [1, 2, 3]\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function dropLast<const ElementType>(iterable: IterableResolvable<ElementType>, count: number): IterableIterator<ElementType> {\n\tcount = assertNotNegative(toIntegerOrInfinityOrThrow(count), count);\n\tconst array = toArray(iterable);\n\tif (array.length <= count) return empty();\n\treturn take(array.values(), array.length - count);\n}\n\nexport { dropLast as skipLast };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -14,5 +14,5 @@ function* dropWhile(iterable, callbackFn) {
|
|
|
14
14
|
__name(dropWhile, "dropWhile");
|
|
15
15
|
|
|
16
16
|
export { dropWhile, dropWhile as skipWhile };
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=dropWhile.mjs.map
|
|
18
18
|
//# sourceMappingURL=dropWhile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/dropWhile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/dropWhile.ts"],"names":[],"mappings":";;;;AA8BO,UAAU,SAAA,CAChB,UACA,UACgC,EAAA;AAChC,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAA,IAAI,CAAC,UAAA,CAAW,KAAO,EAAA,KAAA,EAAO,CAAG,EAAA;AAChC,MAAM,MAAA,KAAA,CAAA;AAAA,KACP;AAAA,GACD;AACD,CAAA;AAZiB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"dropWhile.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates a new iterator without the elements that satisfy the specified test.\n *\n * @param iterable An iterator to drop values from.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return a falsy value to make the element yielded by the iterator helper, and a truthy value otherwise.\n * @returns An iterator that produces elements from the given iterator that don't satisfy the specified test.\n *\n * @example\n * ```typescript\n * import { dropWhile } from '@sapphire/iterator-utilities';\n *\n * const iterable = dropWhile([1, 2, 3, 4, 5], (value) => value < 3);\n * console.log([...iterable]);\n * // Output: [3, 4, 5]\n * ```\n *\n * @seealso {@link filter} or {@link takeWhile} for the opposite behavior.\n */\nexport function dropWhile<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => element is FilteredType\n): IterableIterator<Exclude<ElementType, FilteredType>>;\nexport function dropWhile<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): IterableIterator<ElementType>;\nexport function* dropWhile<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): IterableIterator<ElementType> {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tif (!callbackFn(value, index++)) {\n\t\t\tyield value;\n\t\t}\n\t}\n}\n\nexport { dropWhile as skipWhile };\n"]}
|
package/dist/esm/lib/empty.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { makeIterableIterator } from './shared/_makeIterableIterator.mjs';
|
|
3
3
|
|
|
4
4
|
function empty() {
|
|
@@ -7,5 +7,5 @@ function empty() {
|
|
|
7
7
|
__name(empty, "empty");
|
|
8
8
|
|
|
9
9
|
export { empty };
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=empty.mjs.map
|
|
11
11
|
//# sourceMappingURL=empty.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/empty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/empty.ts"],"names":[],"mappings":";;;AAgBO,SAAS,KAAkE,GAAA;AACjF,EAAA,OAAO,qBAAkC,OAAO,EAAE,MAAM,IAAM,EAAA,KAAA,EAAO,QAAY,CAAA,CAAA,CAAA;AAClF,CAAA;AAFgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"empty.mjs","sourcesContent":["import { makeIterableIterator } from './shared/_makeIterableIterator';\n\n/**\n * Creates an empty iterator.\n *\n * @returns An empty iterator.\n *\n * @example\n * ```typescript\n * import { empty } from '@sapphire/iterator-utilities';\n *\n * const iterable = empty();\n * console.log([...iterable]);\n * // Output: []\n * ```\n */\nexport function empty<const ElementType = never>(): IterableIterator<ElementType> {\n\treturn makeIterableIterator<ElementType>(() => ({ done: true, value: undefined }));\n}\n"]}
|
|
@@ -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* enumerate(iterable) {
|
|
@@ -10,5 +10,5 @@ function* enumerate(iterable) {
|
|
|
10
10
|
__name(enumerate, "enumerate");
|
|
11
11
|
|
|
12
12
|
export { enumerate };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=enumerate.mjs.map
|
|
14
14
|
//# sourceMappingURL=enumerate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/enumerate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/enumerate.ts"],"names":[],"mappings":";;;AAsBO,UAAU,UAA6B,QAAoF,EAAA;AACjI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAM,MAAA,CAAC,SAAS,KAAK,CAAA,CAAA;AAAA,GACtB;AACD,CAAA;AALiB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"enumerate.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates a new iterable that yields the index and value of each element.\n *\n * @param iterable An iterator to enumerate.\n * @returns An iterator that yields the index and value of each element in the source iterator.\n *\n * @example\n * ```typescript\n * import { enumerate } from '@sapphire/iterator-utilities';\n *\n * const iterable = ['a', 'b', 'c'];\n * for (const [index, value] of enumerate(iterable)) {\n * \tconsole.log(`Index: ${index}, Value: ${value}`);\n * \t// Output: Index: 0, Value: a\n * \t// Output: Index: 1, Value: b\n * \t// Output: Index: 2, Value: c\n * }\n * ```\n */\nexport function* enumerate<const ElementType>(iterable: IterableResolvable<ElementType>): IterableIterator<[number, ElementType]> {\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tyield [index++, value];\n\t}\n}\n"]}
|
package/dist/esm/lib/every.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -6,13 +6,12 @@ function every(iterable, callbackFn) {
|
|
|
6
6
|
callbackFn = assertFunction(callbackFn);
|
|
7
7
|
let index = 0;
|
|
8
8
|
for (const value of toIterableIterator(iterable)) {
|
|
9
|
-
if (!callbackFn(value, index++))
|
|
10
|
-
return false;
|
|
9
|
+
if (!callbackFn(value, index++)) return false;
|
|
11
10
|
}
|
|
12
11
|
return true;
|
|
13
12
|
}
|
|
14
13
|
__name(every, "every");
|
|
15
14
|
|
|
16
15
|
export { every };
|
|
17
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=every.mjs.map
|
|
18
17
|
//# sourceMappingURL=every.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/every.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/every.ts"],"names":[],"mappings":";;;;AAmCO,SAAS,KAAA,CAAyB,UAA2C,UAA8D,EAAA;AACjJ,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAA,IAAI,CAAC,UAAA,CAAW,KAAO,EAAA,KAAA,EAAO,GAAU,OAAA,KAAA,CAAA;AAAA,GACzC;AAEA,EAAO,OAAA,IAAA,CAAA;AACR,CAAA;AATgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"every.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Tests whether all elements in the iterable pass the test implemented by the provided function.\n *\n * @param iterable The iterator to check.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return a truthy value to indicate the element passes the test, and a falsy value otherwise.\n * @returns `true` if callbackFn returns a truthy value for every element. Otherwise, `false`.\n *\n * @example\n * ```typescript\n * import { every } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(every(iterable, (value) => value < 10));\n * // Output: true\n *\n * console.log(every(iterable, (value) => value < 3));\n * // Output: false\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function every<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => element is FilteredType\n): iterable is IterableIterator<FilteredType>;\nexport function every<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): boolean;\nexport function every<const ElementType>(iterable: IterableResolvable<ElementType>, callbackFn: (element: ElementType, index: number) => boolean) {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tif (!callbackFn(value, index++)) return false;\n\t}\n\n\treturn true;\n}\n"]}
|
package/dist/esm/lib/filter.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -6,12 +6,11 @@ function* filter(iterable, callbackFn) {
|
|
|
6
6
|
callbackFn = assertFunction(callbackFn);
|
|
7
7
|
let index = 0;
|
|
8
8
|
for (const value of toIterableIterator(iterable)) {
|
|
9
|
-
if (callbackFn(value, index++))
|
|
10
|
-
yield value;
|
|
9
|
+
if (callbackFn(value, index++)) yield value;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
__name(filter, "filter");
|
|
14
13
|
|
|
15
14
|
export { filter, filter as takeWhile };
|
|
16
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=filter.mjs.map
|
|
17
16
|
//# sourceMappingURL=filter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/filter.ts"],"names":[],"mappings":";;;;AA4BO,UAAU,MAAA,CAChB,UACA,UACgC,EAAA;AAChC,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAA,IAAI,UAAW,CAAA,KAAA,EAAO,KAAO,EAAA,CAAA,EAAS,MAAA,KAAA,CAAA;AAAA,GACvC;AACD,CAAA;AAViB,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA","file":"filter.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable with the elements that pass the test implemented by the provided function.\n *\n * @param iterable The iterator to filter.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return a truthy value to make the element yielded by the iterator helper, and a falsy value otherwise.\n * @returns An iterator that produces elements from the given iterator that satisfy the specified test.\n *\n * @example\n * ```typescript\n * import { filter } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log([...filter(iterable, (value) => value % 2 === 0)]);\n * // Output: [2, 4]\n * ```\n */\nexport function filter<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => element is FilteredType\n): IterableIterator<FilteredType>;\nexport function filter<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): IterableIterator<ElementType>;\nexport function* filter<ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): IterableIterator<ElementType> {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tif (callbackFn(value, index++)) yield value;\n\t}\n}\n\nexport { filter as takeWhile };\n"]}
|
package/dist/esm/lib/find.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { filter } from './filter.mjs';
|
|
3
3
|
import { first } from './first.mjs';
|
|
4
4
|
|
|
@@ -8,5 +8,5 @@ function find(iterable, callbackFn) {
|
|
|
8
8
|
__name(find, "find");
|
|
9
9
|
|
|
10
10
|
export { find };
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=find.mjs.map
|
|
12
12
|
//# sourceMappingURL=find.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/find.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/find.ts"],"names":[],"mappings":";;;;AAgCO,SAAS,IAAA,CACf,UACA,UAC0B,EAAA;AAC1B,EAAA,OAAO,KAAM,CAAA,MAAA,CAAO,QAAU,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1C,CAAA;AALgB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA","file":"find.mjs","sourcesContent":["import { filter } from './filter';\nimport { first } from './first';\nimport type { IterableResolvable } from './from';\n\n/**\n * Advances the iterable until it finds the element, returning it if it's found and `undefined` otherwise.\n *\n * @param iterable An iterator to search for a value in.\n * @param callbackFn A function that determines if a value is the one being searched for.\n * @returns\n *\n * @example\n * ```typescript\n * import { find } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(find(iterable, (value) => value % 2 === 0));\n * // Output: 2\n * ```\n *\n * @remarks\n *\n * This function consumes the iterator until the value is found or the iterator is exhausted.\n */\nexport function find<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => element is FilteredType\n): FilteredType | undefined;\nexport function find<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): ElementType | undefined;\nexport function find<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): ElementType | undefined {\n\treturn first(filter(iterable, callbackFn));\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -16,5 +16,5 @@ function findIndex(iterable, callbackFn) {
|
|
|
16
16
|
__name(findIndex, "findIndex");
|
|
17
17
|
|
|
18
18
|
export { findIndex };
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=findIndex.mjs.map
|
|
20
20
|
//# sourceMappingURL=findIndex.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/findIndex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/findIndex.ts"],"names":[],"mappings":";;;;AAwBO,SAAS,SAAA,CACf,UACA,UACS,EAAA;AACT,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,OAAA,IAAW,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACnD,IAAI,IAAA,UAAA,CAAW,OAAS,EAAA,KAAK,CAAG,EAAA;AAC/B,MAAO,OAAA,KAAA,CAAA;AAAA,KACR;AAEA,IAAA,KAAA,EAAA,CAAA;AAAA,GACD;AAEA,EAAO,OAAA,CAAA,CAAA,CAAA;AACR,CAAA;AAhBgB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"findIndex.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Advances the iterable until it finds the element, returning its index if it's found and `-1` otherwise.\n *\n * @param iterable An iterator to search for an element in.\n * @param callbackFn A function that determines if an element is the one being searched for.\n * @returns The index of the first element that satisfies the predicate, or `-1` if no elements satisfy the predicate.\n *\n * @example\n * ```typescript\n * import { findIndex } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(findIndex(iterable, (value) => value % 2 === 0));\n * // Output: 1\n * ```\n *\n * @remarks\n *\n * This function consumes the iterator until the value is found or the iterator is exhausted.\n */\nexport function findIndex<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => boolean\n): number {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const element of toIterableIterator(iterable)) {\n\t\tif (callbackFn(element, index)) {\n\t\t\treturn index;\n\t\t}\n\n\t\tindex++;\n\t}\n\n\treturn -1;\n}\n"]}
|
package/dist/esm/lib/first.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 first(iterable) {
|
|
@@ -7,5 +7,5 @@ function first(iterable) {
|
|
|
7
7
|
__name(first, "first");
|
|
8
8
|
|
|
9
9
|
export { first };
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=first.mjs.map
|
|
11
11
|
//# sourceMappingURL=first.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/first.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/first.ts"],"names":[],"mappings":";;;AAqBO,SAAS,MAAyB,QAAoE,EAAA;AAC5G,EAAA,OAAO,IAAK,CAAA,QAAQ,CAAE,CAAA,IAAA,EAAO,CAAA,KAAA,CAAA;AAC9B,CAAA;AAFgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"first.mjs","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Consumes the first element of the iterable, returning it if it's found and `undefined` otherwise.\n *\n * @param iterable The iterator to return the first value of.\n * @returns The first value of the iterator, or `undefined` if the iterator is empty.\n *\n * @example\n * ```typescript\n * import { first } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(first(iterable));\n * // Output: 1\n * ```\n *\n * @remarks\n *\n * This function consumes the first value of the iterator.\n */\nexport function first<const ElementType>(iterable: IterableResolvable<ElementType>): ElementType | undefined {\n\treturn from(iterable).next().value;\n}\n"]}
|
package/dist/esm/lib/flat.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* flat(iterables) {
|
|
@@ -9,5 +9,5 @@ function* flat(iterables) {
|
|
|
9
9
|
__name(flat, "flat");
|
|
10
10
|
|
|
11
11
|
export { flat };
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=flat.mjs.map
|
|
13
13
|
//# sourceMappingURL=flat.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/flat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/flat.ts"],"names":[],"mappings":";;;AAkBO,UAAU,KAAwB,SAA+F,EAAA;AACvI,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,SAAS,CAAG,EAAA;AAClD,IAAA,OAAO,mBAAmB,KAAK,CAAA,CAAA;AAAA,GAChC;AACD,CAAA;AAJiB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA","file":"flat.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable that yields the elements of each iterable in the input iterable.\n *\n * @param iterables An iterator to map.\n * @returns An iterator that yields the entries of each iterator.\n *\n * @example\n * ```typescript\n * import { flat } from '@sapphire/iterator-utilities';\n *\n * const iterable = flat([[1, 2], [3, 4], [5, 6]]);\n * console.log([...iterable]);\n * // Output: [1, 2, 3, 4, 5, 6]\n * ```\n */\nexport function* flat<const ElementType>(iterables: IterableResolvable<IterableResolvable<ElementType>>): IterableIterator<ElementType> {\n\tfor (const value of toIterableIterator(iterables)) {\n\t\tyield* toIterableIterator(value);\n\t}\n}\n"]}
|
package/dist/esm/lib/flatMap.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ function* flatMap(iterable, callbackFn) {
|
|
|
12
12
|
__name(flatMap, "flatMap");
|
|
13
13
|
|
|
14
14
|
export { flatMap };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=flatMap.mjs.map
|
|
16
16
|
//# sourceMappingURL=flatMap.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/flatMap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/flatMap.ts"],"names":[],"mappings":";;;;AAoBO,UAAU,OAAA,CAChB,UACA,UAC+B,EAAA;AAC/B,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAA,OAAO,kBAAmB,CAAA,UAAA,CAAW,KAAO,EAAA,KAAA,EAAO,CAAC,CAAA,CAAA;AAAA,GACrD;AACD,CAAA;AAViB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"flatMap.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable that yields the elements of each iterable returned by the provided function on each element of the input iterable.\n *\n * @param iterable An iterator to map.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return an iterator or iterable that yields elements to be yielded by `flatMap()`, or a single non-iterator/iterable value to be yielded.\n * @returns An iterator that applies a function to each element of the input iterator and yields the results.\n *\n * @example\n * ```typescript\n * import { flatMap } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3];\n * console.log([...flatMap(iterable, (value) => [value, value * 2])]);\n * // Output: [1, 2, 2, 4, 3, 6]\n * ```\n */\nexport function* flatMap<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => IterableResolvable<MappedType>\n): IterableIterator<MappedType> {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tyield* toIterableIterator(callbackFn(value, index++));\n\t}\n}\n"]}
|
package/dist/esm/lib/forEach.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ function forEach(iterable, callbackFn) {
|
|
|
12
12
|
__name(forEach, "forEach");
|
|
13
13
|
|
|
14
14
|
export { forEach };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=forEach.mjs.map
|
|
16
16
|
//# sourceMappingURL=forEach.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/forEach.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/forEach.ts"],"names":[],"mappings":";;;;AAuBO,SAAS,OAAA,CACf,UACA,UACO,EAAA;AACP,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,OAAA,IAAW,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACnD,IAAA,UAAA,CAAW,SAAS,KAAO,EAAA,CAAA,CAAA;AAAA,GAC5B;AACD,CAAA;AAVgB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"forEach.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Executes a provided function once for each iterable element.\n *\n * @param iterable An iterator to iterate over.\n * @param callbackFn A function to execute for each element produced by the iterator. Its return value is discarded.\n *\n * @example\n * ```typescript\n * import { forEach } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * forEach(iterable, (value) => console.log(value));\n * // Output: 1, 2, 3, 4, 5\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function forEach<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => void\n): void {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const element of toIterableIterator(iterable)) {\n\t\tcallbackFn(element, index++);\n\t}\n}\n"]}
|
package/dist/esm/lib/from.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
|
|
3
3
|
// src/lib/from.ts
|
|
4
4
|
function from(value) {
|
|
@@ -18,5 +18,5 @@ function from(value) {
|
|
|
18
18
|
__name(from, "from");
|
|
19
19
|
|
|
20
20
|
export { from };
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=from.mjs.map
|
|
22
22
|
//# sourceMappingURL=from.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/from.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/from.ts"],"names":[],"mappings":";;;AAmBO,SAAS,KAAK,KAAY,EAAA;AAChC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,KAAA,KAAU,IAAM,EAAA;AAChD,IAAA,IAAI,OAAO,KAAA,CAAM,MAAO,CAAA,QAAQ,MAAM,UAAY,EAAA;AACjD,MAAO,OAAA,KAAA,CAAM,MAAO,CAAA,QAAQ,CAAE,EAAA,CAAA;AAAA,KAC/B;AAEA,IAAI,IAAA,OAAO,KAAM,CAAA,IAAA,KAAS,UAAY,EAAA;AACrC,MAAO,OAAA,KAAA,CAAA;AAAA,KACR;AAAA,GACD;AAEA,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC9B,IAAO,OAAA,KAAA,CAAM,MAAO,CAAA,QAAQ,CAAE,EAAA,CAAA;AAAA,GAC/B;AAEA,EAAA,MAAM,IAAI,SAAU,CAAA,CAAA,EAAG,MAAO,CAAA,KAAK,CAAC,CAAqC,mCAAA,CAAA,CAAA,CAAA;AAC1E,CAAA;AAhBgB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA","file":"from.mjs","sourcesContent":["/**\n * Resolves an iterable from an iterable or iterator-like object.\n *\n * @param value The value to convert to an iterator.\n *\n * @example\n * ```typescript\n * import { from } from '@sapphire/iterator-utilities';\n *\n * const iterable = from([1, 2, 3, 4, 5]);\n * for (const element of iterable) {\n * \tconsole.log(element);\n * \t// Output: 1, 2, 3, 4, 5\n * }\n * ```\n */\nexport function from<const ElementType, const ResolvableType extends IterableResolvable<ElementType>>(\n\tvalue: ResolvableType\n): IterableResolved<ResolvableType>;\nexport function from(value: any) {\n\tif (typeof value === 'object' && value !== null) {\n\t\tif (typeof value[Symbol.iterator] === 'function') {\n\t\t\treturn value[Symbol.iterator]();\n\t\t}\n\n\t\tif (typeof value.next === 'function') {\n\t\t\treturn value;\n\t\t}\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn value[Symbol.iterator]();\n\t}\n\n\tthrow new TypeError(`${String(value)} cannot be converted to an iterable`);\n}\n\nexport type IterableResolvable<ElementType> = Iterable<ElementType> | Iterator<ElementType> | IterableIterator<ElementType>;\n\nexport type IterableResolved<Type> =\n\tType extends IterableIterator<infer Output>\n\t\t? IterableIterator<Output>\n\t\t: Type extends Iterable<infer Output>\n\t\t\t? Iterator<Output>\n\t\t\t: Type extends Iterator<infer Output>\n\t\t\t\t? Iterator<Output>\n\t\t\t\t: never;\n"]}
|
package/dist/esm/lib/indexOf.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 indexOf(iterable, value) {
|
|
@@ -14,5 +14,5 @@ function indexOf(iterable, value) {
|
|
|
14
14
|
__name(indexOf, "indexOf");
|
|
15
15
|
|
|
16
16
|
export { indexOf, indexOf as position };
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=indexOf.mjs.map
|
|
18
18
|
//# sourceMappingURL=indexOf.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/indexOf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/indexOf.ts"],"names":[],"mappings":";;;AAuBO,SAAS,OAAA,CAA2B,UAA2C,KAA4B,EAAA;AACjH,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,OAAA,IAAW,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACnD,IAAA,IAAI,YAAY,KAAO,EAAA;AACtB,MAAO,OAAA,KAAA,CAAA;AAAA,KACR;AAEA,IAAA,KAAA,EAAA,CAAA;AAAA,GACD;AAEA,EAAO,OAAA,CAAA,CAAA,CAAA;AACR,CAAA;AAXgB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"indexOf.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Advances the iterable until it finds the element, returning its index if it's found and `-1` otherwise.\n *\n * @param iterable An iterator to search for a value in.\n * @param value The value to search for.\n * @returns The index of the first occurrence of the value in the iterator, or `-1` if the value is not found.\n *\n * @example\n * ```typescript\n * import { indexOf } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(indexOf(iterable, 3));\n * // Output: 2\n * ```\n *\n * @remarks\n *\n * This function consumes the iterator until the value is found or the iterator is exhausted.\n */\nexport function indexOf<const ElementType>(iterable: IterableResolvable<ElementType>, value: ElementType): number {\n\tlet index = 0;\n\tfor (const element of toIterableIterator(iterable)) {\n\t\tif (element === value) {\n\t\t\treturn index;\n\t\t}\n\n\t\tindex++;\n\t}\n\n\treturn -1;\n}\n\nexport { indexOf as position };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { filter } from './filter.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -9,5 +9,5 @@ function intersect(first, second) {
|
|
|
9
9
|
__name(intersect, "intersect");
|
|
10
10
|
|
|
11
11
|
export { intersect };
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=intersect.mjs.map
|
|
13
13
|
//# sourceMappingURL=intersect.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/intersect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/intersect.ts"],"names":[],"mappings":";;;;AAyBO,SAAS,SAAA,CACf,OACA,MACgC,EAAA;AAChC,EAAA,MAAM,GAAM,GAAA,IAAI,GAAI,CAAA,kBAAA,CAAmB,MAAM,CAAC,CAAA,CAAA;AAC9C,EAAA,OAAO,OAAO,KAAO,EAAA,CAAC,UAAU,GAAI,CAAA,GAAA,CAAI,KAAK,CAAC,CAAA,CAAA;AAC/C,CAAA;AANgB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"intersect.mjs","sourcesContent":["import { filter } from './filter';\nimport type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable with the elements that are in both input iterables.\n *\n * @param first An iterator to return elements from.\n * @param second An iterator that contains elements to include in the result.\n *\n * @example\n * ```typescript\n * import { intersect } from '@sapphire/iterator-utilities';\n *\n * const iterable = intersect([1, 2, 3, 4, 5], [3, 4, 5, 6, 7]);\n * console.log([...iterable]);\n * // Output: [3, 4, 5]\n * ```\n *\n * @remarks\n *\n * This function consumes the entire `second` iterator to build the set of elements to intersect with `first`.\n *\n * @seealso {@link difference} for the opposite behavior.\n */\nexport function intersect<const ElementType>(\n\tfirst: IterableResolvable<ElementType>,\n\tsecond: IterableResolvable<ElementType>\n): IterableIterator<ElementType> {\n\tconst set = new Set(toIterableIterator(second));\n\treturn filter(first, (value) => set.has(value));\n}\n"]}
|
package/dist/esm/lib/isEmpty.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 isEmpty(iterable) {
|
|
@@ -7,5 +7,5 @@ function isEmpty(iterable) {
|
|
|
7
7
|
__name(isEmpty, "isEmpty");
|
|
8
8
|
|
|
9
9
|
export { isEmpty };
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=isEmpty.mjs.map
|
|
11
11
|
//# sourceMappingURL=isEmpty.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/isEmpty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/isEmpty.ts"],"names":[],"mappings":";;;AAuBO,SAAS,QAA2B,QAAoD,EAAA;AAC9F,EAAA,OAAO,IAAK,CAAA,QAAQ,CAAE,CAAA,IAAA,GAAO,IAAQ,IAAA,KAAA,CAAA;AACtC,CAAA;AAFgB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"isEmpty.mjs","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Advances the iterable once, returning `true` if it's exhausted and `false` otherwise.\n *\n * @param iterable The iterator to check for emptiness.\n * @returns `true` if the iterator is empty; otherwise, `false`.\n *\n * @example\n * ```typescript\n * import { isEmpty } from '@sapphire/iterator-utilities';\n *\n * console.log(isEmpty([]));\n * // Output: true\n *\n * console.log(isEmpty([1, 2, 3, 4, 5]));\n * // Output: false\n * ```\n *\n * @remarks\n *\n * This function consumes the first value of the iterator.\n */\nexport function isEmpty<const ElementType>(iterable: IterableResolvable<ElementType>): boolean {\n\treturn from(iterable).next().done ?? false;\n}\n"]}
|
package/dist/esm/lib/last.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 last(iterable) {
|
|
@@ -11,5 +11,5 @@ function last(iterable) {
|
|
|
11
11
|
__name(last, "last");
|
|
12
12
|
|
|
13
13
|
export { last };
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=last.mjs.map
|
|
15
15
|
//# sourceMappingURL=last.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/last.ts"],"names":["last"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/last.ts"],"names":["last"],"mappings":";;;AAsBO,SAAS,KAAwB,QAAoE,EAAA;AAC3G,EAAIA,IAAAA,KAAAA,CAAAA;AACJ,EAAW,KAAA,MAAA,KAAA,IAAS,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAAA,KAAO,GAAA,KAAA,CAAA;AAAA,GACR;AAEA,EAAOA,OAAAA,KAAAA,CAAAA;AACR,CAAA;AAPgB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA","file":"last.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable until it's exhausted, returning the last element.\n *\n * @param iterable An iterator to return the last value of.\n * @returns The value at the last position in the source iterator, or `undefined` if the iterator is empty.\n *\n * @example\n * ```typescript\n * import { last } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(last(iterable));\n * // Output: 5\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator to find the last value.\n */\nexport function last<const ElementType>(iterable: IterableResolvable<ElementType>): ElementType | undefined {\n\tlet last: ElementType | undefined;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tlast = value;\n\t}\n\n\treturn last;\n}\n"]}
|
package/dist/esm/lib/map.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
2
2
|
import { assertFunction } from './shared/_assertFunction.mjs';
|
|
3
3
|
import { toIterableIterator } from './toIterableIterator.mjs';
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ function* map(iterable, callbackFn) {
|
|
|
12
12
|
__name(map, "map");
|
|
13
13
|
|
|
14
14
|
export { map };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=map.mjs.map
|
|
16
16
|
//# sourceMappingURL=map.mjs.map
|
package/dist/esm/lib/map.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/map.ts"],"names":[],"mappings":";;;;AAmBO,UAAU,GAAA,CAChB,UACA,UAC+B,EAAA;AAC/B,EAAA,UAAA,GAAa,eAAe,UAAU,CAAA,CAAA;AAEtC,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AACZ,EAAW,KAAA,MAAA,OAAA,IAAW,kBAAmB,CAAA,QAAQ,CAAG,EAAA;AACnD,IAAM,MAAA,UAAA,CAAW,SAAS,KAAO,EAAA,CAAA,CAAA;AAAA,GAClC;AACD,CAAA;AAViB,MAAA,CAAA,GAAA,EAAA,KAAA,CAAA","file":"map.mjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterable with the results of calling a provided function on each element.\n *\n * @param iterable An iterator to map over.\n * @param callbackFn A function to execute for each element produced by the iterator. Its return value is yielded by the iterator helper.\n *\n * @example\n * ```typescript\n * import { map } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log([...map(iterable, (value) => value * 2)]);\n * // Output: [2, 4, 6, 8, 10]\n * ```\n */\nexport function* map<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => MappedType\n): IterableIterator<MappedType> {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index = 0;\n\tfor (const element of toIterableIterator(iterable)) {\n\t\tyield callbackFn(element, index++);\n\t}\n}\n"]}
|