Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yannickdot/taskify
util.promisify but for Tasks ! 🙌
https://github.com/yannickdot/taskify
async futures javascript task taskify tasks
Last synced: about 6 hours ago
JSON representation
util.promisify but for Tasks ! 🙌
- Host: GitHub
- URL: https://github.com/yannickdot/taskify
- Owner: YannickDot
- License: mit
- Created: 2017-06-04T00:45:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-13T19:44:04.000Z (about 7 years ago)
- Last Synced: 2024-09-17T09:54:05.012Z (about 2 months ago)
- Topics: async, futures, javascript, task, taskify, tasks
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Taskify
`util.promisify` but for Tasks ! 🙌
## Install
```
yarn add util.taskify
```or
```
npm install util.taskify
```⚠️ You must give `taskify` the Task data type of your choice.
I suggest you to try [`Fluture`](https://github.com/fluture-js/Fluture) or [`Taskorama`](https://github.com/YannickDot/Taskorama).
## Usage
For a single function :
```js
const taskify = require('util.taskify')
const fs = require('fs')
const Task = require('taskorama')
// or
// const Task = require('fluture')const readFileTask = taskify(Task, fs.readFile)
readFileTask('package.json', 'utf8')
.fork(
err => console.error('Failed.', err),
str => console.log('Done!', str)
)
```Or for a whole module :
```js
const taskify = require('util.taskify')
const fs = require('fs')
const Task = require('taskorama')
// or
// const Task = require('fluture')const Filesystem = taskify(Task, fs)
Filesystem.readFile('package.json', 'utf8')
.fork(
err => console.error('Failed.', err),
str => console.log('Done!', str)
)
```#### BONUS
If you like currying (using ramda `curry()` function) :
```js
const { curry } = require('ramda')
const util_taskify = require('util.taskify')
const fs = require('fs')
const Task = require('taskorama')
// or
// const Task = require('fluture')
//const taskify = curry(util_taskify)
const taskifier = taskify(Task)const readFileTask = taskifier(fs.readFile)
readFileTask('package.json')
.fork(
err => console.error('Failed.', err),
str => console.log('Done!', str)
)
```