0.0.2 • Published 10 years ago

flyd-forwardto v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

flyd-forwardto

Create a new stream that passes all values through a function and forwards them to a target stream.

This function is inspired by the Elm function of the same name.

Signature

Stream b -> (a -> b) -> Stream a

Example

// We create a stream of numbers
var numbers = flyd.stream();
// And another stream that squares the numbers
var squaredNumbers = flyd.map(function(n) { return n*n; }, numbers);
// Add a logger just for show
flyd.map(function(n) { console.log(n); }, squaredNumbers);
// For some reason we have a lot of string of numbers, but we can't
// send them down the `numbers` stream. That would wreck havoc in the
// squaring function. `forwardTo` to the resque!
var stringNumbers = forwardTo(numbers, parseInt);
stringNumbers('7'); // `49` is logged
0.0.2

10 years ago

0.0.1

10 years ago