combine
combines some transform methods to a transform method.
function combine(...tfs: TransduceFunction[]): TransduceFunction
Collection<A> => Collection<B>
function map<T, K>(f: Map<T, K>): TransduceFunction<T, K>
function scan<T, K>(f: Scan<T, K>, v: K): TransduceFunction<T, K>
function filter<T>(f: Predicate<T>): TransduceFunction<T, T>
function remove<T>(f: Predicate<T>): TransduceFunction<T, T>
function take<T>(n: number): TransduceFunction<T, T>
function takeWhile<T>(f: Predicate<T>): TransduceFunction<T, T>
function skip<T>(n: number): TransduceFunction<T, T>
function skipWhile<T>(f: Predicate<T>): TransduceFunction<T, T>
function partition<T>(n: number): TransduceFunction<T, T[]>
function partitionBy<T>(f: Map<T, any>): TransduceFunction<T, T[]>
function flatten<T>(): TransduceFunction<T[], T>
function groupBy<T, Key, K>(f: Group<T, Key>, gr: GroupByReduce<T, Key, K>): TransduceFunction<T, K>
function groupByReduce<T, Key, K>(k: Key): TransduceHandler<T, K>
Get transduce handler by each-once/transduce
.
import * as Transduce from "each-once/transduce";
import { combine, groupBy, take, foreach } from "each-once";
import * as Transduce from "each-once/transduce";
const s = function* () {
while (true) {
yield Math.random() * 10;
}
};
foreach(
(x: number[]) => console.log(x),
combine(
take<number>(100),
groupBy(
(x: number) => Math.floor(x),
(key) => Transduce.toArray(take<number>(10))
)
)
)(s());
Collection<A> => B
function count<T>(tf: TransduceFunction<T, any>): (iter: Iterable<T>) => number
function include<T, K>(v: K, tf: TransduceFunction<T, K>): (iter: Iterable<T>) => boolean
function every<T, K>(f: Predicate<K>, tf: TransduceFunction<T, K>): (iter: Iterable<T>) => boolean
function some<T, K>(f: Predicate<K>, tf: TransduceFunction<T, K>): (iter: Iterable<T>) => boolean
function first<T, K>(tf: TransduceFunction<T, K>): (iter: Iterable<T>) => K | void
function last<T, K>(tf: TransduceFunction<T, K>): (iter: Iterable<T>) => K | void
function reduce<T, K, R>(rf: ReduceFunction<K, R>, v: R, tf: TransduceFunction<T, K>): (iter: Iterable<T>) => R
function foreach<T, K>(f: Action<K>, tf: TransduceFunction<T, K>): (iter: Iterable<T>) => void
function toArray<T, K>(tf: TransduceFunction<T, K>): (iter: Iterable<T>) => K[]
Use async by each-once/async
and each-once/async/transduce