Nanobots Producing Megastructures

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

@basic-streams/map2

1.0.0 • Public • Published

@basic-streams/map2

map2<A, B, C>(
  fn: (a: A, b: B) => C,
  streamAStream<A>,
  streamBStream<B>,
)Stream<C>

Creates a stream containing fn(a, b) where a and b are the latest values from streamA and streamB. The resulting stream updates when any of source stream update.

import ofMany from "@basic-streams/of-many"
import map2 from "@basic-streams/map2"
 
const streamA = ofMany([2, 4], 10000)
const streamB = ofMany([1, 3], 8000)
const result = map2((a, b) => a + b, streamA, streamB)
 
result(x => {
  console.log(x)
})
 
// > 3
// > 5
// > 7
 
// streamA: _________2_________4
// streamB: _______1_______3
// result:  _________3_____5___7

install

npm i @basic-streams/map2

Downloadsweekly downloads

2

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability