no-stream alias ns, used to create a stream.
function ns<T>(iter: {
[Symbol.iterator](): IterableIterator<T>;
} | (() => IterableIterator<T>)): NS<T>
Stream<T>[] => Stream<T>
concat<T>(ns: NS<T>, ...nss: NS<T>[]): NS<T>
NoStream alias NS.
Stream<A> => Stream<B>
NS<T>.map<K>(f: Map<T, K>): NS<K>
NS<T>.scan<K>(f: Scan<T, K>, v: K): NS<K>
NS<T>.filter(f: Predicate<T>): NS<T>
NS<T>.remove(f: Predicate<T>): NS<T>
NS<T>.take(n: number): NS<T>
NS<T>.takeWhile(f: Predicate<T>): NS<T>
NS<T>.skip(n: number): NS<T>
NS<T>.skipWhile(f: Predicate<T>): NS<T>
NS<T>.partition(n: number): NS<T[]>
NS<T>.partitionBy(f: Map<T, any>): NS<T[]>
NS<T>.flatten(): T extends (infer K)[] ? NS<K> : never
NS<T>.groupBy<Key, K>(f: Group<T, Key>, gr: GroupByReduce<T, Key, K>): NS<K>
function groupByReduce<T, Key, K>(k: Key): TransduceHandler<T, K>
Get transduce handler by nsr, which is an alias for NoStreamReduce.
import { nsr } from "no-stream";
import { ns, nsr } from "no-stream";
const s = ns(function* () {
while (true) {
yield Math.random() * 10;
}
});
s.take(100)
.groupBy(
(x) => Math.floor(x),
(key) => nsr<number>().take(10).toArray()
)
.foreach((x) => console.log(x));
Stream<A> => B
NS<T>.count(): number
NS<T>.include(v: T): boolean
NS<T>.include(v: T): boolean
NS<T>.some(f: Predicate<T>): boolean
NS<T>.first(): T | void
NS<T>.last(): T | void
NS<T>.reduce<K>(rf: ReduceFunction<T, K>, v: K): K
NS<T>.foreach(f: Action<T>): void
NS<T>.toArray(): T[]
Stream<T>[] => Stream<T>
NS<T>.concat(...nss: NS<T>[]): NS<T>
Async no-stream alias ans, used to create a async stream.
function ans<T>(iter: {
[Symbol.iterator](): IterableIterator<T>;
} | (() => AsyncIterableIterator<T>)): ANS<T>
Create a async stream by observable.
observable<T>(subscribe: (subscriber: Subscriber<T>) => void | Unsubscribable): ANS<T>
Similar to ns.concat.
Stream<A, B, C, ...>[] => Stream<[A, B, C, ...]>
zip<T extends ANS<any>[]>(...anss_0: T): ANS<Zip<T>>
Stream<T>[] => Stream<T>
ANS<T>.race<T>(...anss: ANS<T>[]): ANS<T>
AsyncNoStream alias ANS, similar to NS.