@cspell/cspell-pipe 6.18.0 → 6.19.0
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/helpers/distribute.d.ts +13 -0
- package/dist/cjs/helpers/index.d.ts +7 -0
- package/dist/cjs/helpers/interleave.d.ts +2 -0
- package/dist/cjs/helpers/iteratorToIterable.d.ts +3 -0
- package/dist/cjs/helpers/toArray.d.ts +6 -0
- package/dist/cjs/helpers/toAsyncIterable.d.ts +11 -0
- package/dist/cjs/helpers/util.d.ts +4 -0
- package/dist/cjs/index.cjs +644 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/internalTypes.d.ts +17 -0
- package/dist/{operators/append.js → cjs/operators/append.cjs} +10 -8
- package/dist/cjs/operators/append.d.ts +15 -0
- package/dist/{operators/await.js → cjs/operators/await.cjs} +3 -4
- package/dist/cjs/operators/await.d.ts +2 -0
- package/dist/{operators/combine.js → cjs/operators/combine.cjs} +4 -5
- package/dist/cjs/operators/combine.d.ts +23 -0
- package/dist/{operators/concatMap.js → cjs/operators/concatMap.cjs} +16 -8
- package/dist/cjs/operators/concatMap.d.ts +4 -0
- package/dist/{operators/filter.js → cjs/operators/filter.cjs} +10 -8
- package/dist/cjs/operators/filter.d.ts +10 -0
- package/dist/{operators/first.js → cjs/operators/first.cjs} +10 -8
- package/dist/cjs/operators/first.d.ts +10 -0
- package/dist/{operators/flatten.js → cjs/operators/flatten.cjs} +16 -8
- package/dist/cjs/operators/flatten.d.ts +4 -0
- package/dist/cjs/operators/helpers/distribute.d.ts +13 -0
- package/dist/cjs/operators/helpers/index.d.ts +7 -0
- package/dist/cjs/operators/helpers/interleave.d.ts +2 -0
- package/dist/cjs/operators/helpers/iteratorToIterable.d.ts +3 -0
- package/dist/cjs/operators/helpers/toArray.d.ts +6 -0
- package/dist/cjs/operators/helpers/toAsyncIterable.d.ts +11 -0
- package/dist/cjs/operators/helpers/util.d.ts +4 -0
- package/dist/cjs/operators/index.cjs +508 -0
- package/dist/cjs/operators/index.d.ts +17 -0
- package/dist/cjs/operators/internalTypes.d.ts +17 -0
- package/dist/cjs/operators/joinStrings.cjs +49 -0
- package/dist/cjs/operators/joinStrings.d.ts +4 -0
- package/dist/{operators/last.js → cjs/operators/last.cjs} +10 -8
- package/dist/cjs/operators/last.d.ts +10 -0
- package/dist/{operators/map.js → cjs/operators/map.cjs} +16 -8
- package/dist/cjs/operators/map.d.ts +4 -0
- package/dist/cjs/operators/operators/append.d.ts +15 -0
- package/dist/cjs/operators/operators/await.d.ts +2 -0
- package/dist/cjs/operators/operators/combine.d.ts +23 -0
- package/dist/cjs/operators/operators/concatMap.d.ts +4 -0
- package/dist/cjs/operators/operators/filter.d.ts +10 -0
- package/dist/cjs/operators/operators/first.d.ts +10 -0
- package/dist/cjs/operators/operators/flatten.d.ts +4 -0
- package/dist/cjs/operators/operators/index.d.ts +17 -0
- package/dist/cjs/operators/operators/joinStrings.d.ts +4 -0
- package/dist/cjs/operators/operators/last.d.ts +10 -0
- package/dist/cjs/operators/operators/map.d.ts +4 -0
- package/dist/cjs/operators/operators/reduce.d.ts +7 -0
- package/dist/cjs/operators/operators/skip.d.ts +4 -0
- package/dist/cjs/operators/operators/take.d.ts +8 -0
- package/dist/cjs/operators/operators/tap.d.ts +19 -0
- package/dist/cjs/operators/operators/types.d.ts +4 -0
- package/dist/cjs/operators/operators/unique.d.ts +4 -0
- package/dist/cjs/operators/pipe.d.ts +20 -0
- package/dist/{operators/reduce.js → cjs/operators/reduce.cjs} +22 -11
- package/dist/cjs/operators/reduce.d.ts +7 -0
- package/dist/{operators/skip.js → cjs/operators/skip.cjs} +16 -8
- package/dist/cjs/operators/skip.d.ts +4 -0
- package/dist/cjs/operators/sync/index.d.ts +6 -0
- package/dist/{operators/take.js → cjs/operators/take.cjs} +16 -8
- package/dist/cjs/operators/take.d.ts +8 -0
- package/dist/{operators/tap.js → cjs/operators/tap.cjs} +16 -8
- package/dist/cjs/operators/tap.d.ts +19 -0
- package/dist/cjs/operators/types.cjs +2 -0
- package/dist/cjs/operators/types.d.ts +4 -0
- package/dist/{operators/unique.js → cjs/operators/unique.cjs} +16 -8
- package/dist/cjs/operators/unique.d.ts +4 -0
- package/dist/cjs/pipe.d.ts +20 -0
- package/dist/cjs/reduce.d.ts +16 -0
- package/dist/cjs/sync/helpers/distribute.d.ts +13 -0
- package/dist/cjs/sync/helpers/index.d.ts +7 -0
- package/dist/cjs/sync/helpers/interleave.d.ts +2 -0
- package/dist/cjs/sync/helpers/iteratorToIterable.d.ts +3 -0
- package/dist/cjs/sync/helpers/toArray.d.ts +6 -0
- package/dist/cjs/sync/helpers/toAsyncIterable.d.ts +11 -0
- package/dist/cjs/sync/helpers/util.d.ts +4 -0
- package/dist/cjs/sync/index.cjs +245 -0
- package/dist/cjs/sync/index.d.ts +6 -0
- package/dist/cjs/sync/internalTypes.d.ts +17 -0
- package/dist/cjs/sync/operators/append.d.ts +15 -0
- package/dist/cjs/sync/operators/await.d.ts +2 -0
- package/dist/cjs/sync/operators/combine.d.ts +23 -0
- package/dist/cjs/sync/operators/concatMap.d.ts +4 -0
- package/dist/cjs/sync/operators/filter.d.ts +10 -0
- package/dist/cjs/sync/operators/first.d.ts +10 -0
- package/dist/cjs/sync/operators/flatten.d.ts +4 -0
- package/dist/cjs/sync/operators/index.d.ts +17 -0
- package/dist/cjs/sync/operators/joinStrings.d.ts +4 -0
- package/dist/cjs/sync/operators/last.d.ts +10 -0
- package/dist/cjs/sync/operators/map.d.ts +4 -0
- package/dist/cjs/sync/operators/reduce.d.ts +7 -0
- package/dist/cjs/sync/operators/skip.d.ts +4 -0
- package/dist/cjs/sync/operators/take.d.ts +8 -0
- package/dist/cjs/sync/operators/tap.d.ts +19 -0
- package/dist/cjs/sync/operators/types.d.ts +4 -0
- package/dist/cjs/sync/operators/unique.d.ts +4 -0
- package/dist/cjs/sync/pipe.d.ts +20 -0
- package/dist/cjs/sync/reduce.d.ts +16 -0
- package/dist/cjs/sync/sync/index.d.ts +6 -0
- package/dist/esm/helpers/distribute.d.ts +13 -0
- package/dist/{helpers → esm/helpers}/distribute.js +2 -6
- package/dist/esm/helpers/index.d.ts +7 -0
- package/dist/esm/helpers/index.js +7 -0
- package/dist/esm/helpers/interleave.d.ts +2 -0
- package/dist/{helpers → esm/helpers}/interleave.js +1 -5
- package/dist/esm/helpers/iteratorToIterable.d.ts +3 -0
- package/dist/esm/helpers/iteratorToIterable.js +13 -0
- package/dist/esm/helpers/toArray.d.ts +6 -0
- package/dist/esm/helpers/toArray.js +15 -0
- package/dist/esm/helpers/toAsyncIterable.d.ts +11 -0
- package/dist/esm/helpers/toAsyncIterable.js +15 -0
- package/dist/esm/helpers/util.d.ts +4 -0
- package/dist/esm/helpers/util.js +10 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/internalTypes.d.ts +17 -0
- package/dist/esm/internalTypes.js +2 -0
- package/dist/esm/operators/append.d.ts +15 -0
- package/dist/esm/operators/append.js +36 -0
- package/dist/esm/operators/await.d.ts +2 -0
- package/dist/esm/operators/await.js +9 -0
- package/dist/esm/operators/combine.d.ts +23 -0
- package/dist/esm/operators/combine.js +19 -0
- package/dist/esm/operators/concatMap.d.ts +4 -0
- package/dist/esm/operators/concatMap.js +19 -0
- package/dist/esm/operators/filter.d.ts +10 -0
- package/dist/esm/operators/filter.js +30 -0
- package/dist/esm/operators/first.d.ts +10 -0
- package/dist/esm/operators/first.js +34 -0
- package/dist/esm/operators/flatten.d.ts +4 -0
- package/dist/esm/operators/flatten.js +19 -0
- package/dist/esm/operators/index.d.ts +17 -0
- package/dist/esm/operators/index.js +16 -0
- package/dist/esm/operators/joinStrings.d.ts +4 -0
- package/dist/esm/operators/joinStrings.js +22 -0
- package/dist/esm/operators/last.d.ts +10 -0
- package/dist/esm/operators/last.js +39 -0
- package/dist/esm/operators/map.d.ts +4 -0
- package/dist/esm/operators/map.js +19 -0
- package/dist/esm/operators/reduce.d.ts +7 -0
- package/dist/esm/operators/reduce.js +49 -0
- package/dist/esm/operators/skip.d.ts +4 -0
- package/dist/esm/operators/skip.js +27 -0
- package/dist/esm/operators/take.d.ts +8 -0
- package/dist/esm/operators/take.js +31 -0
- package/dist/esm/operators/tap.d.ts +19 -0
- package/dist/esm/operators/tap.js +36 -0
- package/dist/esm/operators/types.d.ts +4 -0
- package/dist/esm/operators/types.js +2 -0
- package/dist/esm/operators/unique.d.ts +4 -0
- package/dist/esm/operators/unique.js +53 -0
- package/dist/esm/pipe.d.ts +20 -0
- package/dist/esm/pipe.js +10 -0
- package/dist/esm/reduce.d.ts +16 -0
- package/dist/esm/reduce.js +21 -0
- package/dist/esm/sync/index.d.ts +6 -0
- package/dist/esm/sync/index.js +5 -0
- package/dist/helpers/index.d.ts +6 -6
- package/dist/helpers/toAsyncIterable.d.ts +1 -1
- package/dist/helpers/util.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/operators/append.d.ts +1 -1
- package/dist/operators/combine.d.ts +2 -2
- package/dist/operators/concatMap.d.ts +1 -1
- package/dist/operators/filter.d.ts +1 -1
- package/dist/operators/first.d.ts +1 -1
- package/dist/operators/flatten.d.ts +1 -1
- package/dist/operators/index.d.ts +16 -16
- package/dist/operators/joinStrings.d.ts +1 -1
- package/dist/operators/last.d.ts +1 -1
- package/dist/operators/map.d.ts +1 -1
- package/dist/operators/skip.d.ts +1 -1
- package/dist/operators/take.d.ts +1 -1
- package/dist/operators/tap.d.ts +1 -1
- package/dist/operators/unique.d.ts +1 -1
- package/dist/pipe.d.ts +1 -1
- package/dist/reduce.d.ts +1 -1
- package/dist/sync/index.d.ts +5 -5
- package/package.json +59 -25
- package/dist/helpers/index.js +0 -17
- package/dist/helpers/iteratorToIterable.js +0 -18
- package/dist/helpers/toArray.js +0 -21
- package/dist/helpers/toAsyncIterable.js +0 -19
- package/dist/helpers/util.js +0 -15
- package/dist/index.js +0 -58
- package/dist/internalTypes.js +0 -3
- package/dist/operators/index.js +0 -60
- package/dist/operators/joinStrings.js +0 -28
- package/dist/operators/types.js +0 -3
- package/dist/pipe.js +0 -15
- package/dist/reduce.js +0 -26
- package/dist/sync/index.js +0 -26
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AnyIterable } from '../internalTypes.js';
|
|
2
|
+
export declare function mergeAsyncIterables<T>(iter: Iterable<T>): AsyncIterable<T>;
|
|
3
|
+
export declare function mergeAsyncIterables<T>(iter: AsyncIterable<T>): AsyncIterable<T>;
|
|
4
|
+
export declare function mergeAsyncIterables<T>(iter: Promise<Iterable<T>>): AsyncIterable<T>;
|
|
5
|
+
export declare function mergeAsyncIterables<T>(iter: AnyIterable<T>): AsyncIterable<T>;
|
|
6
|
+
export declare function mergeAsyncIterables<T>(iter: AnyIterable<T>, ...rest: AnyIterable<T>[]): AsyncIterable<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Convert one or more iterables to an AsyncIterable
|
|
9
|
+
*/
|
|
10
|
+
export declare const toAsyncIterable: typeof mergeAsyncIterables;
|
|
11
|
+
//# sourceMappingURL=toAsyncIterable.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge multiple iterables into an AsyncIterable
|
|
3
|
+
* @param iter - initial iterable.
|
|
4
|
+
* @param rest - iterables to merge.
|
|
5
|
+
*/
|
|
6
|
+
export async function* mergeAsyncIterables(iter, ...rest) {
|
|
7
|
+
for await (const i of [iter, ...rest]) {
|
|
8
|
+
yield* i;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convert one or more iterables to an AsyncIterable
|
|
13
|
+
*/
|
|
14
|
+
export const toAsyncIterable = mergeAsyncIterables;
|
|
15
|
+
//# sourceMappingURL=toAsyncIterable.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyIterable, PipeFn, PipeFnAsync, PipeFnSync } from '../internalTypes.js';
|
|
2
|
+
export declare function toPipeFn<T, U = T>(syncFn: PipeFnSync<T, U>, asyncFn: PipeFnAsync<T, U>): PipeFn<T, U>;
|
|
3
|
+
export declare function isAsyncIterable<T>(i: AnyIterable<T>): i is AsyncIterable<T>;
|
|
4
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function toPipeFn(syncFn, asyncFn) {
|
|
2
|
+
function _(i) {
|
|
3
|
+
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
4
|
+
}
|
|
5
|
+
return _;
|
|
6
|
+
}
|
|
7
|
+
export function isAsyncIterable(i) {
|
|
8
|
+
return typeof i[Symbol.asyncIterator] === 'function';
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _helpers from './helpers/index.js';
|
|
2
|
+
import * as _operators from './operators/index.js';
|
|
3
|
+
export { interleave, isAsyncIterable, toArray, toAsyncIterable, toDistributableIterable } from './helpers/index.js';
|
|
4
|
+
export { opAppend, opAwaitAsync, opConcatMap, opFilter, opFirst, opFlatten, opJoinStrings, opLast, opMap, opSkip, opTake, opTap, opUnique, } from './operators/index.js';
|
|
5
|
+
export { pipeAsync, pipeSync } from './pipe.js';
|
|
6
|
+
export { reduce, reduceAsync, reduceSync } from './reduce.js';
|
|
7
|
+
export declare const operators: typeof _operators;
|
|
8
|
+
export declare const helpers: typeof _helpers;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _helpers from './helpers/index.js';
|
|
2
|
+
import * as _operators from './operators/index.js';
|
|
3
|
+
export { interleave, isAsyncIterable, toArray, toAsyncIterable, toDistributableIterable } from './helpers/index.js';
|
|
4
|
+
export { opAppend, opAwaitAsync, opConcatMap, opFilter, opFirst, opFlatten, opJoinStrings, opLast, opMap, opSkip, opTake, opTap, opUnique, } from './operators/index.js';
|
|
5
|
+
export { pipeAsync, pipeSync } from './pipe.js';
|
|
6
|
+
export { reduce, reduceAsync, reduceSync } from './reduce.js';
|
|
7
|
+
// eslint-disable-next-line unicorn/prefer-export-from
|
|
8
|
+
export const operators = _operators;
|
|
9
|
+
// eslint-disable-next-line unicorn/prefer-export-from
|
|
10
|
+
export const helpers = _helpers;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PipeFnSync<T, U> {
|
|
2
|
+
(iter: Iterable<T>): Iterable<U>;
|
|
3
|
+
/** This is just to help TypeScript figure out the type. */
|
|
4
|
+
__PipeFnSync__?: [T, U];
|
|
5
|
+
}
|
|
6
|
+
export interface PipeFnAsync<T, U> {
|
|
7
|
+
(iter: AsyncIterable<T>): AsyncIterable<U>;
|
|
8
|
+
/** This is just to help TypeScript figure out the type. */
|
|
9
|
+
__PipeFnAsync__?: [T, U];
|
|
10
|
+
}
|
|
11
|
+
export type PipeFn<T, U> = PipeFnSync<T, U> & PipeFnAsync<T, U>;
|
|
12
|
+
export type PsFn<T, U> = PipeFnSync<T, U> | ((i: Iterable<T>) => Iterable<U>);
|
|
13
|
+
export type AnyIterable<T> = Iterable<T> | AsyncIterable<T> | Promise<Iterable<T>> | Iterable<Promise<T>>;
|
|
14
|
+
export type PaFn<T, U> = PipeFnAsync<T, U> | ((i: AsyncIterable<T>) => AsyncIterable<U>);
|
|
15
|
+
export type PipeAsyncTx<T extends [...any]> = T extends [infer Left, infer Right, ...infer Rest] ? Rest extends [any, ...any] ? [PaFn<Left, Right>, ...PipeAsyncTx<[Right, ...Rest]>] : [PaFn<Left, Right>] : never;
|
|
16
|
+
export type PipeSyncTx<T extends [...any]> = T extends [infer Left, infer Right, ...infer Rest] ? Rest extends [any, ...any] ? [PsFn<Left, Right>, ...PipeSyncTx<[Right, ...Rest]>] : [PsFn<Left, Right>] : never;
|
|
17
|
+
//# sourceMappingURL=internalTypes.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PipeFn } from '../internalTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Append values onto the end of an iterable.
|
|
4
|
+
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function opAppendAsync<T>(...iterablesToAppend: (AsyncIterable<T> | Iterable<T>)[]): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Append values onto the end of an iterable.
|
|
10
|
+
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function opAppendSync<T>(...iterablesToAppend: Iterable<T>[]): (iter: Iterable<T>) => Iterable<T>;
|
|
14
|
+
export declare function opAppend<T>(...iterablesToAppend: Iterable<T>[]): PipeFn<T, T>;
|
|
15
|
+
//# sourceMappingURL=append.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isAsyncIterable } from '../helpers/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Append values onto the end of an iterable.
|
|
4
|
+
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function opAppendAsync(...iterablesToAppend) {
|
|
8
|
+
async function* fn(iter) {
|
|
9
|
+
yield* iter;
|
|
10
|
+
for (const i of iterablesToAppend) {
|
|
11
|
+
yield* i;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return fn;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Append values onto the end of an iterable.
|
|
18
|
+
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export function opAppendSync(...iterablesToAppend) {
|
|
22
|
+
function* fn(iter) {
|
|
23
|
+
yield* iter;
|
|
24
|
+
for (const i of iterablesToAppend) {
|
|
25
|
+
yield* i;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return fn;
|
|
29
|
+
}
|
|
30
|
+
export function opAppend(...iterablesToAppend) {
|
|
31
|
+
function _(i) {
|
|
32
|
+
return isAsyncIterable(i) ? opAppendAsync(...iterablesToAppend)(i) : opAppendSync(...iterablesToAppend)(i);
|
|
33
|
+
}
|
|
34
|
+
return _;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=append.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PaFn, PipeAsyncTx, PipeSyncTx, PsFn } from '../internalTypes.js';
|
|
2
|
+
import type { OperatorAsync, OperatorSync } from './types.js';
|
|
3
|
+
export declare function opCombineAsync<T>(): OperatorAsync<T>;
|
|
4
|
+
export declare function opCombineAsync<T, T0>(...f: PipeAsyncTx<[T, T0]>): OperatorAsync<T0>;
|
|
5
|
+
export declare function opCombineAsync<T, T0, T1>(...f: PipeAsyncTx<[T, T0, T1]>): OperatorAsync<T1>;
|
|
6
|
+
export declare function opCombineAsync<T, T0, T1, T2>(...f: PipeAsyncTx<[T, T0, T1, T2]>): OperatorAsync<T2>;
|
|
7
|
+
export declare function opCombineAsync<T, T0, T1, T2, T3>(...f: PipeAsyncTx<[T, T0, T1, T2, T3]>): OperatorAsync<T3>;
|
|
8
|
+
export declare function opCombineAsync<T, T0, T1, T2, T3, T4>(...f: PipeAsyncTx<[T, T0, T1, T2, T3, T4]>): OperatorAsync<T4>;
|
|
9
|
+
export declare function opCombineAsync<T, T0, T1, T2, T3, T4, T5>(...f: PipeAsyncTx<[T, T0, T1, T2, T3, T4, T5]>): OperatorAsync<T5>;
|
|
10
|
+
export declare function opCombineAsync<T, T0, T1, T2, T3, T4, T5, T6>(...f: PipeAsyncTx<[T, T0, T1, T2, T3, T4, T5, T6]>): OperatorAsync<T6>;
|
|
11
|
+
export declare function opCombineAsync<T, T0, T1, T2, T3, T4, T5, T6, T7>(...f: PipeAsyncTx<[T, T0, T1, T2, T3, T4, T5, T6, T7]>): OperatorAsync<T7>;
|
|
12
|
+
export declare function opCombineAsync<T>(...fns: PaFn<T, T>[]): OperatorAsync<T>;
|
|
13
|
+
export declare function opCombineSync<T>(): OperatorSync<T>;
|
|
14
|
+
export declare function opCombineSync<T, T0 = T>(...f: PipeSyncTx<[T, T0]>): OperatorSync<T0>;
|
|
15
|
+
export declare function opCombineSync<T, T0, T1>(...f: PipeSyncTx<[T, T0, T1]>): OperatorSync<T1>;
|
|
16
|
+
export declare function opCombineSync<T, T0, T1, T2>(...f: PipeSyncTx<[T, T0, T1, T2]>): OperatorSync<T2>;
|
|
17
|
+
export declare function opCombineSync<T, T0, T1, T2, T3>(...f: PipeSyncTx<[T, T0, T1, T2, T3]>): OperatorSync<T3>;
|
|
18
|
+
export declare function opCombineSync<T, T0, T1, T2, T3, T4>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4]>): OperatorSync<T4>;
|
|
19
|
+
export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4, T5]>): OperatorSync<T5>;
|
|
20
|
+
export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5, T6>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4, T5, T6]>): OperatorSync<T6>;
|
|
21
|
+
export declare function opCombineSync<T, T0, T1, T2, T3, T4, T5, T6, T7>(...f: PipeSyncTx<[T, T0, T1, T2, T3, T4, T5, T6, T7]>): OperatorSync<T7>;
|
|
22
|
+
export declare function opCombineSync<T>(...fns: PsFn<T, T>[]): OperatorSync<T>;
|
|
23
|
+
//# sourceMappingURL=combine.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function opCombineAsync(...fns) {
|
|
2
|
+
function combine(iter) {
|
|
3
|
+
for (const fn of fns) {
|
|
4
|
+
iter = fn(iter);
|
|
5
|
+
}
|
|
6
|
+
return iter;
|
|
7
|
+
}
|
|
8
|
+
return combine;
|
|
9
|
+
}
|
|
10
|
+
export function opCombineSync(...fns) {
|
|
11
|
+
function combine(iter) {
|
|
12
|
+
for (const fn of fns) {
|
|
13
|
+
iter = fn(iter);
|
|
14
|
+
}
|
|
15
|
+
return iter;
|
|
16
|
+
}
|
|
17
|
+
return combine;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=combine.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function opConcatMapAsync<T, U = T>(mapFn: (v: T) => AsyncIterable<U> | Iterable<U>): (iter: AsyncIterable<T>) => AsyncIterable<U>;
|
|
2
|
+
export declare function opConcatMapSync<T, U = T>(mapFn: (v: T) => Iterable<U>): (iter: Iterable<T>) => Iterable<U>;
|
|
3
|
+
export declare const opConcatMap: <T, U>(fn: (v: T) => Iterable<U>) => import("../internalTypes.js").PipeFn<T, U>;
|
|
4
|
+
//# sourceMappingURL=concatMap.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
2
|
+
export function opConcatMapAsync(mapFn) {
|
|
3
|
+
async function* fn(iter) {
|
|
4
|
+
for await (const v of iter) {
|
|
5
|
+
yield* mapFn(v);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return fn;
|
|
9
|
+
}
|
|
10
|
+
export function opConcatMapSync(mapFn) {
|
|
11
|
+
function* fn(iter) {
|
|
12
|
+
for (const v of iter) {
|
|
13
|
+
yield* mapFn(v);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
export const opConcatMap = (fn) => toPipeFn(opConcatMapSync(fn), opConcatMapAsync(fn));
|
|
19
|
+
//# sourceMappingURL=concatMap.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PipeFn } from '../internalTypes.js';
|
|
2
|
+
export declare function opFilterAsync<T, S extends T>(filterFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
3
|
+
export declare function opFilterAsync<T, S extends Awaited<T>>(filterFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
4
|
+
export declare function opFilterAsync<T>(filterFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
5
|
+
export declare function opFilterAsync<T>(filterFn: (v: Awaited<T>) => Promise<boolean>): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
6
|
+
export declare function opFilterSync<T, S extends T>(filterFn: (v: T) => v is S): (iter: Iterable<T>) => Iterable<S>;
|
|
7
|
+
export declare function opFilterSync<T>(filterFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
|
|
8
|
+
export declare function opFilter<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
|
|
9
|
+
export declare function opFilter<T>(fn: (v: T) => boolean): PipeFn<T, T>;
|
|
10
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isAsyncIterable } from '../helpers/util.js';
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export function opFilterAsync(filterFn) {
|
|
4
|
+
async function* fn(iter) {
|
|
5
|
+
for await (const v of iter) {
|
|
6
|
+
const pass = await filterFn(v);
|
|
7
|
+
if (pass)
|
|
8
|
+
yield v;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return fn;
|
|
12
|
+
}
|
|
13
|
+
export function opFilterSync(filterFn) {
|
|
14
|
+
function* fn(iter) {
|
|
15
|
+
for (const v of iter) {
|
|
16
|
+
if (filterFn(v))
|
|
17
|
+
yield v;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return fn;
|
|
21
|
+
}
|
|
22
|
+
export function opFilter(fn) {
|
|
23
|
+
const asyncFn = opFilterAsync(fn);
|
|
24
|
+
const syncFn = opFilterSync(fn);
|
|
25
|
+
function _(i) {
|
|
26
|
+
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
27
|
+
}
|
|
28
|
+
return _;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PipeFn } from '../internalTypes.js';
|
|
2
|
+
export declare function opFirstAsync<T, S extends T>(firstFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
3
|
+
export declare function opFirstAsync<T, S extends Awaited<T>>(firstFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
4
|
+
export declare function opFirstAsync<T>(firstFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
5
|
+
export declare function opFirstAsync<T>(firstFn: (v: Awaited<T>) => Promise<boolean>): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
6
|
+
export declare function opFirstSync<T, S extends T>(firstFn: (v: T) => v is S): (iter: Iterable<T>) => Iterable<S>;
|
|
7
|
+
export declare function opFirstSync<T>(firstFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
|
|
8
|
+
export declare function opFirst<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
|
|
9
|
+
export declare function opFirst<T>(fn: (v: T) => boolean): PipeFn<T, T>;
|
|
10
|
+
//# sourceMappingURL=first.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isAsyncIterable } from '../helpers/util.js';
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export function opFirstAsync(firstFn) {
|
|
4
|
+
async function* fn(iter) {
|
|
5
|
+
for await (const v of iter) {
|
|
6
|
+
const pass = await firstFn(v);
|
|
7
|
+
if (pass) {
|
|
8
|
+
yield v;
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return fn;
|
|
14
|
+
}
|
|
15
|
+
export function opFirstSync(firstFn) {
|
|
16
|
+
function* fn(iter) {
|
|
17
|
+
for (const v of iter) {
|
|
18
|
+
if (firstFn(v)) {
|
|
19
|
+
yield v;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
export function opFirst(fn) {
|
|
27
|
+
const asyncFn = opFirstAsync(fn);
|
|
28
|
+
const syncFn = opFirstSync(fn);
|
|
29
|
+
function _(i) {
|
|
30
|
+
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
31
|
+
}
|
|
32
|
+
return _;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=first.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function opFlattenAsync<T>(): (iter: AsyncIterable<AsyncIterable<T> | Iterable<T>>) => AsyncIterable<T>;
|
|
2
|
+
export declare function opFlattenSync<T>(): (iter: Iterable<Iterable<T>>) => Iterable<T>;
|
|
3
|
+
export declare const opFlatten: <T>() => import("../internalTypes.js").PipeFn<Iterable<T>, T>;
|
|
4
|
+
//# sourceMappingURL=flatten.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
2
|
+
export function opFlattenAsync() {
|
|
3
|
+
async function* fn(iter) {
|
|
4
|
+
for await (const v of iter) {
|
|
5
|
+
yield* v;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return fn;
|
|
9
|
+
}
|
|
10
|
+
export function opFlattenSync() {
|
|
11
|
+
function* fn(iter) {
|
|
12
|
+
for (const v of iter) {
|
|
13
|
+
yield* v;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
export const opFlatten = () => toPipeFn(opFlattenSync(), opFlattenAsync());
|
|
19
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { opAppend, opAppendAsync, opAppendSync } from './append.js';
|
|
2
|
+
export { opAwaitAsync } from './await.js';
|
|
3
|
+
export { opCombineAsync, opCombineSync } from './combine.js';
|
|
4
|
+
export { opConcatMap, opConcatMapAsync, opConcatMapSync } from './concatMap.js';
|
|
5
|
+
export { opFilter, opFilterAsync, opFilterSync } from './filter.js';
|
|
6
|
+
export { opFirst, opFirstAsync, opFirstSync } from './first.js';
|
|
7
|
+
export { opFlatten, opFlattenAsync, opFlattenSync } from './flatten.js';
|
|
8
|
+
export { opJoinStrings, opJoinStringsAsync, opJoinStringsSync } from './joinStrings.js';
|
|
9
|
+
export { opLast, opLastAsync, opLastSync } from './last.js';
|
|
10
|
+
export { opMap, opMapAsync, opMapSync } from './map.js';
|
|
11
|
+
export { opReduceAsync, opReduceSync } from './reduce.js';
|
|
12
|
+
export { opSkip, opSkipAsync, opSkipSync } from './skip.js';
|
|
13
|
+
export { opTake, opTakeAsync, opTakeSync } from './take.js';
|
|
14
|
+
export { opTap, opTapAsync, opTapSync } from './tap.js';
|
|
15
|
+
export type { OperatorAsync, OperatorSync, OperatorSyncToAsync } from './types.js';
|
|
16
|
+
export { opUnique, opUniqueAsync, opUniqueSync } from './unique.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { opAppend, opAppendAsync, opAppendSync } from './append.js';
|
|
2
|
+
export { opAwaitAsync } from './await.js';
|
|
3
|
+
export { opCombineAsync, opCombineSync } from './combine.js';
|
|
4
|
+
export { opConcatMap, opConcatMapAsync, opConcatMapSync } from './concatMap.js';
|
|
5
|
+
export { opFilter, opFilterAsync, opFilterSync } from './filter.js';
|
|
6
|
+
export { opFirst, opFirstAsync, opFirstSync } from './first.js';
|
|
7
|
+
export { opFlatten, opFlattenAsync, opFlattenSync } from './flatten.js';
|
|
8
|
+
export { opJoinStrings, opJoinStringsAsync, opJoinStringsSync } from './joinStrings.js';
|
|
9
|
+
export { opLast, opLastAsync, opLastSync } from './last.js';
|
|
10
|
+
export { opMap, opMapAsync, opMapSync } from './map.js';
|
|
11
|
+
export { opReduceAsync, opReduceSync } from './reduce.js';
|
|
12
|
+
export { opSkip, opSkipAsync, opSkipSync } from './skip.js';
|
|
13
|
+
export { opTake, opTakeAsync, opTakeSync } from './take.js';
|
|
14
|
+
export { opTap, opTapAsync, opTapSync } from './tap.js';
|
|
15
|
+
export { opUnique, opUniqueAsync, opUniqueSync } from './unique.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function opJoinStringsAsync(joinCharacter?: string): (iter: AsyncIterable<AsyncIterable<string> | Iterable<string>>) => AsyncIterable<string>;
|
|
2
|
+
export declare function opJoinStringsSync(joinCharacter?: string): (iter: Iterable<Iterable<string>>) => Iterable<string>;
|
|
3
|
+
export declare const opJoinStrings: (joinCharacter?: string) => import("../internalTypes.js").PipeFn<Iterable<string>, string>;
|
|
4
|
+
//# sourceMappingURL=joinStrings.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { toArray } from '../helpers/toArray.js';
|
|
2
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
3
|
+
export function opJoinStringsAsync(joinCharacter = ',') {
|
|
4
|
+
async function* fn(iter) {
|
|
5
|
+
for await (const v of iter) {
|
|
6
|
+
const a = await toArray(v);
|
|
7
|
+
yield a.join(joinCharacter);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return fn;
|
|
11
|
+
}
|
|
12
|
+
export function opJoinStringsSync(joinCharacter = ',') {
|
|
13
|
+
function* fn(iter) {
|
|
14
|
+
for (const v of iter) {
|
|
15
|
+
const a = toArray(v);
|
|
16
|
+
yield a.join(joinCharacter);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return fn;
|
|
20
|
+
}
|
|
21
|
+
export const opJoinStrings = (joinCharacter) => toPipeFn(opJoinStringsSync(joinCharacter), opJoinStringsAsync(joinCharacter));
|
|
22
|
+
//# sourceMappingURL=joinStrings.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PipeFn } from '../internalTypes.js';
|
|
2
|
+
export declare function opLastAsync<T, S extends T>(lastFn: (v: T) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
3
|
+
export declare function opLastAsync<T, S extends Awaited<T>>(lastFn: (v: Awaited<T>) => v is S): (iter: AsyncIterable<T>) => AsyncIterable<S>;
|
|
4
|
+
export declare function opLastAsync<T>(lastFn: (v: Awaited<T>) => boolean): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
5
|
+
export declare function opLastAsync<T>(lastFn: (v: Awaited<T>) => Promise<boolean>): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
6
|
+
export declare function opLastSync<T, S extends T>(lastFn: (v: T) => v is S): (iter: Iterable<T>) => Iterable<S>;
|
|
7
|
+
export declare function opLastSync<T>(lastFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
|
|
8
|
+
export declare function opLast<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
|
|
9
|
+
export declare function opLast<T>(fn: (v: T) => boolean): PipeFn<T, T>;
|
|
10
|
+
//# sourceMappingURL=last.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isAsyncIterable } from '../helpers/util.js';
|
|
2
|
+
const symNotFound = Symbol('LastNotFound');
|
|
3
|
+
// prettier-ignore
|
|
4
|
+
export function opLastAsync(lastFn) {
|
|
5
|
+
async function* fn(iter) {
|
|
6
|
+
let last = symNotFound;
|
|
7
|
+
for await (const v of iter) {
|
|
8
|
+
const pass = await lastFn(v);
|
|
9
|
+
if (pass) {
|
|
10
|
+
last = v;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (last !== symNotFound)
|
|
14
|
+
yield last;
|
|
15
|
+
}
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
export function opLastSync(lastFn) {
|
|
19
|
+
function* fn(iter) {
|
|
20
|
+
let last = symNotFound;
|
|
21
|
+
for (const v of iter) {
|
|
22
|
+
if (lastFn(v)) {
|
|
23
|
+
last = v;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (last !== symNotFound)
|
|
27
|
+
yield last;
|
|
28
|
+
}
|
|
29
|
+
return fn;
|
|
30
|
+
}
|
|
31
|
+
export function opLast(fn) {
|
|
32
|
+
const asyncFn = opLastAsync(fn);
|
|
33
|
+
const syncFn = opLastSync(fn);
|
|
34
|
+
function _(i) {
|
|
35
|
+
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
36
|
+
}
|
|
37
|
+
return _;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=last.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function opMapAsync<T, U = T>(mapFn: (v: T) => U): (iter: AsyncIterable<T>) => AsyncIterable<U>;
|
|
2
|
+
export declare function opMapSync<T, U = T>(mapFn: (v: T) => U): (iter: Iterable<T>) => Iterable<U>;
|
|
3
|
+
export declare const opMap: <T, U>(fn: (v: T) => U) => import("../internalTypes.js").PipeFn<T, U>;
|
|
4
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
2
|
+
export function opMapAsync(mapFn) {
|
|
3
|
+
async function* fn(iter) {
|
|
4
|
+
for await (const v of iter) {
|
|
5
|
+
yield mapFn(v);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return fn;
|
|
9
|
+
}
|
|
10
|
+
export function opMapSync(mapFn) {
|
|
11
|
+
function* fn(iter) {
|
|
12
|
+
for (const v of iter) {
|
|
13
|
+
yield mapFn(v);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
export const opMap = (fn) => toPipeFn(opMapSync(fn), opMapAsync(fn));
|
|
19
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function opReduceAsync<T>(reduceFn: (previousValue: T, currentValue: T) => T): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
2
|
+
export declare function opReduceAsync<T>(reduceFn: (previousValue: T, currentValue: T) => T, initialValue: T | Promise<T>): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
3
|
+
export declare function opReduceAsync<T, U>(reduceFn: (previousValue: U, currentValue: T) => U, initialValue: U | Promise<U>): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<U>;
|
|
4
|
+
export declare function opReduceSync<T>(reduceFn: (previousValue: T, currentValue: T) => T): (iter: Iterable<T>) => Iterable<T>;
|
|
5
|
+
export declare function opReduceSync<T>(reduceFn: (previousValue: T, currentValue: T) => T, initialValue: T): (iter: Iterable<T>) => Iterable<T>;
|
|
6
|
+
export declare function opReduceSync<T, U>(reduceFn: (previousValue: U, currentValue: T) => U, initialValue: U): (iter: Iterable<T>) => Iterable<U>;
|
|
7
|
+
//# sourceMappingURL=reduce.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { asyncIteratorToAsyncIterable, iteratorToIterable } from '../helpers/index.js';
|
|
2
|
+
export function opReduceAsync(reduceFn, initialValue) {
|
|
3
|
+
async function* reduce(head, tail) {
|
|
4
|
+
for await (const v of tail) {
|
|
5
|
+
head = reduceFn(head, v);
|
|
6
|
+
}
|
|
7
|
+
yield head;
|
|
8
|
+
}
|
|
9
|
+
async function* fn(iter) {
|
|
10
|
+
const ht = initialValue === undefined ? await headTailAsync(iter) : { head: await initialValue, tail: iter };
|
|
11
|
+
if (!ht)
|
|
12
|
+
return;
|
|
13
|
+
yield* reduce(ht.head, ht.tail);
|
|
14
|
+
}
|
|
15
|
+
return fn;
|
|
16
|
+
}
|
|
17
|
+
export function opReduceSync(reduceFn, initialValue) {
|
|
18
|
+
function* reduce(head, tail) {
|
|
19
|
+
for (const v of tail) {
|
|
20
|
+
head = reduceFn(head, v);
|
|
21
|
+
}
|
|
22
|
+
yield head;
|
|
23
|
+
}
|
|
24
|
+
function* fn(iter) {
|
|
25
|
+
const ht = initialValue === undefined ? headTail(iter) : { head: initialValue, tail: iter };
|
|
26
|
+
if (!ht)
|
|
27
|
+
return;
|
|
28
|
+
yield* reduce(ht.head, ht.tail);
|
|
29
|
+
}
|
|
30
|
+
return fn;
|
|
31
|
+
}
|
|
32
|
+
function headTail(iter) {
|
|
33
|
+
const iterator = iter[Symbol.iterator]();
|
|
34
|
+
const first = iterator.next();
|
|
35
|
+
if (first.done)
|
|
36
|
+
return undefined;
|
|
37
|
+
return { head: first.value, tail: iteratorToIterable(iterator) };
|
|
38
|
+
}
|
|
39
|
+
async function headTailAsync(iter) {
|
|
40
|
+
const iterator = isIterable(iter) ? iter[Symbol.iterator]() : iter[Symbol.asyncIterator]();
|
|
41
|
+
const first = await iterator.next();
|
|
42
|
+
if (first.done)
|
|
43
|
+
return undefined;
|
|
44
|
+
return { head: first.value, tail: asyncIteratorToAsyncIterable(iterator) };
|
|
45
|
+
}
|
|
46
|
+
function isIterable(i) {
|
|
47
|
+
return typeof i[Symbol.iterator] === 'function';
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=reduce.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function opSkipAsync<T>(count: number): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
2
|
+
export declare function opSkipSync<T>(count: number): (iter: Iterable<T>) => Iterable<T>;
|
|
3
|
+
export declare const opSkip: <T>(count: number) => import("../internalTypes.js").PipeFn<T, T>;
|
|
4
|
+
//# sourceMappingURL=skip.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
2
|
+
export function opSkipAsync(count) {
|
|
3
|
+
async function* fn(iter) {
|
|
4
|
+
for await (const v of iter) {
|
|
5
|
+
if (count > 0) {
|
|
6
|
+
--count;
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
yield v;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return fn;
|
|
13
|
+
}
|
|
14
|
+
export function opSkipSync(count) {
|
|
15
|
+
function* fn(iter) {
|
|
16
|
+
for (const v of iter) {
|
|
17
|
+
if (count > 0) {
|
|
18
|
+
--count;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
yield v;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
export const opSkip = (count) => toPipeFn(opSkipSync(count), opSkipAsync(count));
|
|
27
|
+
//# sourceMappingURL=skip.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function opTakeAsync<T>(count: number): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
2
|
+
export declare function opTakeSync<T>(count: number): (iter: Iterable<T>) => Iterable<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Consume only the first `count` number from the iterable.
|
|
5
|
+
* @param count - number to take
|
|
6
|
+
*/
|
|
7
|
+
export declare const opTake: <T>(count: number) => import("../internalTypes.js").PipeFn<T, T>;
|
|
8
|
+
//# sourceMappingURL=take.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { toPipeFn } from '../helpers/util.js';
|
|
2
|
+
export function opTakeAsync(count) {
|
|
3
|
+
async function* fn(iter) {
|
|
4
|
+
if (count <= 0)
|
|
5
|
+
return;
|
|
6
|
+
for await (const v of iter) {
|
|
7
|
+
yield v;
|
|
8
|
+
if (--count <= 0)
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return fn;
|
|
13
|
+
}
|
|
14
|
+
export function opTakeSync(count) {
|
|
15
|
+
function* fn(iter) {
|
|
16
|
+
if (count <= 0)
|
|
17
|
+
return;
|
|
18
|
+
for (const v of iter) {
|
|
19
|
+
yield v;
|
|
20
|
+
if (--count <= 0)
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Consume only the first `count` number from the iterable.
|
|
28
|
+
* @param count - number to take
|
|
29
|
+
*/
|
|
30
|
+
export const opTake = (count) => toPipeFn(opTakeSync(count), opTakeAsync(count));
|
|
31
|
+
//# sourceMappingURL=take.js.map
|