data.task

data.task

A structure for representing asynchronous actions with automatic resource handling.

data.task monad which can be used to replace Continuation-Passing Style form of programming, in order to be able to compose and sequence time-dependent effects using the generic and powerful monadic operations.

GET IT: npm install --save data.task

Sample Usage:

1
2
3
var Task = require('data.task');
> new Task((reject, resolve) => {})
Task { fork: [Function], cleanup: [Function] }
1
2
3
4
5
6
7
8
9
10
11
12
13
var Task = require('data.task');
var read = path => {
return new Task((reject, resolve) => {
  fs.readFile(path, (err, data) => {
        if (err)  {
          reject(err)
        } else {
          resolve(data)
        }
    });
  });
};
read('/tmp/data.md').fork(console.error, console.log);

GIF FTW:

data.task

Suggest a module

Comments