task-from-fn
v0.1.7
Published
Wrap a JavaScript function with callback in a Task
Downloads
7
Maintainers
Readme
NOTE: this library's functionality has now been implemented in Folktale: https://origamitower.github.io/folktale/en/folktale.data.task.fromnodeback.html
task-from-fn
Convert a JavaScript function with node-style callback in to a Task from the data.task package.
Installation
$ npm install task-from-fn --save
or with yarn,
$ yarn add task-from-fn
Usage
const taskFromFn = require('task-from-fn')
const fs = require('fs')
const readFile = taskFromFn(fs.readFile)
const task = readFile('path/to/file', 'utf-8')
task.fork(
e => console.error(e), // handle error
data => console.log(data) // handle file data
)