@basic-streams/take
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@basic-streams/take

take<T>(n: number, stream: Stream<T>): Stream<T>

Creates a stream containing only first n events from the source stream.

import ofMany from "@basic-streams/of-many"
import take from "@basic-streams/take"

const stream = ofMany([1, 2, 3], 5000)
const result = take(2, stream)

result(x => {
  console.log(x)
})

// > 1
// > 2

// stream: ____1____2!
// result: ____1____2

/@basic-streams/take/

    Package Sidebar

    Install

    npm i @basic-streams/take

    Weekly Downloads

    3

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.71 kB

    Total Files

    8

    Last publish

    Collaborators

    • pozadi