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

1.0.0 • Public • Published

@basic-streams/map

map<T, U>(fn: (x: T) => U, stream: Stream<T>): Stream<U>

Creates a stream containing fn(x) for each value x from the source stream.

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

const stream = ofMany([1, 2, 3], 5000)
const result = map(x => x * 2, stream)

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

// > 2
// > 4
// > 6

// stream: ____1____2____3
// result: ____2____4____6

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @basic-streams/map

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.46 kB

    Total Files

    8

    Last publish

    Collaborators

    • pozadi