JSPM

  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q43534F

Type-safety piping paradigram through webstream-kernels.

Package Exports

  • snoflow
  • snoflow/fromNodeStream

Readme

SNOFLOW

Examples

Pipe style

await snoflow([1, 2, 3])
    .buffer(2)
    .debounce(100)
    .filter()
    .map((n) => [String(n)])
    .flat()
    .flatMap((n) => [String(n)])
    .tees((s) => s.pipeTo(nils()))
    .limit(1)
    .map(() => 1)
    .peek(() => {})
    .reduce(0, (a, b) => a + b)
    .skip(1)
    .tail(1)
    .throttle(100)
    .done()

Using native ReadableStream snoflow kernels to allow tree-shaking

await new ReadableStream({
    start:(ctrl)=>{
        [1, 2, 3].map(x=> ctrl.enqueue(x))
    }
})
    .pipeThrough(buffers(2))
    .pipeThrough(debounces(100))
    .pipeThrough(filters())
    .pipeThrough(maps((n) => [String(n)]))
    .pipeThrough(flats())
    .pipeThrough(flatMaps((n) => [String(n)]))
    .pipeThrough(teess((s) => s.pipeTo(nils())))
    .pipeThrough(limits(1))
    .pipeThrough(maps(() => 1))
    .pipeThrough(peeks(() => {}))
    .pipeThrough(reduces(0, (a, b) => a + b))
    .pipeThrough(skips(1))
    .pipeThrough(tails(1))
    .pipeThrough(throttles(100))
    .pipeTo(nils())