1.0.3 • Published 7 years ago

futurize-c v1.0.3

Weekly downloads
14
License
CC0-1.0
Repository
github
Last release
7 years ago

futurize-c

Turns a function that takes a node-style callback into a function that returns a future.

install

npm install futurize-c

example

const {Future} = require('ramda-fantasy')
const futurize = require('futurize-c')(Future) // pass in an implementation of Future

const incrementLater = (ms, n, cb) => {
  setTimeout(() => {
    cb(undefined, n + 1)
  }, ms)
}

const futureIncrement = futurize(incrementLater)
futureIncrement(500, 7).fork(
  console.error,
  console.log //=> 8
)