1.0.2 • Published 7 years ago

futurize-p v1.0.2

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

futurize-p

Turns a function that returns a promise into a function that returns a future.

install

npm install futurize-p

example

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

const incrementLater = (ms, n) => new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(n + 1)
  }, ms)
})

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