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

1.0.0 • Public • Published

@basic-streams/take-until

takeUntil<T>(controller: Stream<any>, stream: Stream<T>): Stream<T>

Creates a stream containing values from the given stream that are produced before the first event in the controller stream.

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

const stream = ofMany([1, 2, 3], 5000)
const controller = later(12000, 0)

const result = takeUntil(controller, stream)

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

// > 1
// > 2

// stream:     ____1____2_!
// controller: ___________0!
// result:     ____1____2

Package Sidebar

Install

npm i @basic-streams/take-until

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

8.39 kB

Total Files

8

Last publish

Collaborators

  • pozadi