fork-future
v0.1.0
Published
Pointfree forking `Futures`
Downloads
1
Maintainers
Readme
fork-future
Pointfree forking
Futures
Example
const Task = require('data.task');
const fork = require('fork-future');
const timeout = (msg, time) => new Task((reject, resolve) => setTimeout(() => resolve(msg), time));
const forkAndLog = fork(onRejected, (result) => {
console.log('RESULT', result);
});
forkAndLog(timeout('POINTFREE', 3000));
API
fork :: (a -> *) -> (b -> *) -> Future -> *
fork(onRejected)(onResolved)(future)
forkToPromise :: (Future a b) -> (Promise a b)
const forkToPromise = require('fork-future').forkToPromise;
// Fork, then continue using a promise chain.
forkToPromise(future).then(...)
// Use async/await (if supported in your environment).
await forkToPromise(future)
License
MIT © stoeffel