auto-promised

0.0.3 • Public • Published

auto-promised.js

async.auto but with promises.

Installation:

npm install auto-promised

Usage:

const sleep = dur => new Promise((res, rej) => {
	setTimeout(res, dur);
});

auto({
    task1: ['task2', async (results) => {
        console.log('in task1 with results ', results);
        await sleep(25);
        return 1
    }],
    async task2() {
        await sleep(50)
        return 2
    },
    task3: ['task2', function(){
        return 3
    }],
    task4: ['task1', 'task2', function(){
        return 4
    }],
    task5: ['task2', async function(){
        await sleep(0)
        return 5
    }],
    task6: ['task2', function(){
        return 6
    }]
})
    .then(results => {
        console.log(results)
    });

// in task1 with results  { task2: 2 }
// { task2: 2, task3: 3, task6: 6, task5: 5, task1: 1, task4: 4 }

Readme

Keywords

none

Package Sidebar

Install

npm i auto-promised

Weekly Downloads

37

Version

0.0.3

License

MIT

Unpacked Size

15.4 kB

Total Files

8

Last publish

Collaborators

  • noelzubin