Skip to content

Latest commit

 

History

History
278 lines (194 loc) · 3.98 KB

document.md

File metadata and controls

278 lines (194 loc) · 3.98 KB

document

ns

no-stream alias ns, used to create a stream.

function ns<T>(iter: {
    [Symbol.iterator](): IterableIterator<T>;
} | (() => IterableIterator<T>)): NS<T>

ns.concat

Stream<T>[] => Stream<T>

concat<T>(ns: NS<T>, ...nss: NS<T>[]): NS<T>

NS

NoStream alias NS.

transform method

Stream<A> => Stream<B>

map

NS<T>.map<K>(f: Map<T, K>): NS<K>

scan

NS<T>.scan<K>(f: Scan<T, K>, v: K): NS<K>

filter

NS<T>.filter(f: Predicate<T>): NS<T>

remove

NS<T>.remove(f: Predicate<T>): NS<T>

take

NS<T>.take(n: number): NS<T>

takeWhile

NS<T>.takeWhile(f: Predicate<T>): NS<T>

skip

NS<T>.skip(n: number): NS<T>

skipWhile

NS<T>.skipWhile(f: Predicate<T>): NS<T>

partition

NS<T>.partition(n: number): NS<T[]>

partitionBy

NS<T>.partitionBy(f: Map<T, any>): NS<T[]>

flatten

NS<T>.flatten(): T extends (infer K)[] ? NS<K> : never

groupBy

NS<T>.groupBy<Key, K>(f: Group<T, Key>, gr: GroupByReduce<T, Key, K>): NS<K>
GroupByReduce
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";
usage
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));

reduce method

Stream<A> => B

count

NS<T>.count(): number

include

NS<T>.include(v: T): boolean

every

NS<T>.include(v: T): boolean

some

NS<T>.some(f: Predicate<T>): boolean

first

NS<T>.first(): T | void

last

NS<T>.last(): T | void

reduce

NS<T>.reduce<K>(rf: ReduceFunction<T, K>, v: K): K

foreach

NS<T>.foreach(f: Action<T>): void

toArray

NS<T>.toArray(): T[]

merge method

Stream<T>[] => Stream<T>

concat

NS<T>.concat(...nss: NS<T>[]): NS<T>

ans

Async no-stream alias ans, used to create a async stream.

function ans<T>(iter: {
    [Symbol.iterator](): IterableIterator<T>;
} | (() => AsyncIterableIterator<T>)): ANS<T>

ans.ob

Create a async stream by observable.

observable<T>(subscribe: (subscriber: Subscriber<T>) => void | Unsubscribable): ANS<T>

ans.concat

Similar to ns.concat.

ans.zip

Stream<A, B, C, ...>[] => Stream<[A, B, C, ...]>

zip<T extends ANS<any>[]>(...anss_0: T): ANS<Zip<T>>

ans.race

Stream<T>[] => Stream<T>

ANS<T>.race<T>(...anss: ANS<T>[]): ANS<T>

ANS

AsyncNoStream alias ANS, similar to NS.