Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.
/ task-from-fn Public archive

[migrated to https://origamitower.github.io/folktale/en/folktale.data.task.fromnodeback.html] Wrap a JavaScript function that has a callback in a Task (data.task)

License

Notifications You must be signed in to change notification settings

rpearce/task-from-fn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
)