futurize-c

1.0.3 • Public • Published

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
)

Package Sidebar

Install

npm i futurize-c

Weekly Downloads

2

Version

1.0.3

License

CC0-1.0

Last publish

Collaborators

  • m59