futurize-p

1.0.2 • Public • Published

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(+ 1)
  }, ms)
})
 
const futureIncrement = futurize(incrementLater)
futureIncrement(500, 7).fork(
  console.error,
  console.log //=> 8
)

Package Sidebar

Install

npm i futurize-p

Weekly Downloads

6

Version

1.0.2

License

CC0-1.0

Last publish

Collaborators

  • m59