@basic-streams/take

take operator for basic-streams

Usage no npm install needed!

<script type="module">
  import basicStreamsTake from 'https://cdn.skypack.dev/@basic-streams/take';
</script>

README

@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