Détail du package

do

metarhia2.7kMIT0.7.0

The simplest way to manage asynchronicity

metasync, callback, callbacks, promise

readme

"do" is the simplest way to manage asynchronicity

CI Status NPM Version NPM Downloads/Month NPM Downloads

If you don't want to use all the async/chain libraries but just want a reliable way to know when the function is done - this is for you.

Installation

npm i do

Usage

Series async execution

const chain = require('do');

const c1 = chain
  .do(readConfig, 'myConfig')
  .do(selectFromDb, 'select * from cities')
  .do(getHttpPage, 'http://kpi.ua')
  .do(readFile, 'README.md');

c1((err, result) => {
  console.log('done');
  if (err) console.log(err);
  else console.dir({ result });
});

Data collector

const chain = require('do');
const fs = require('fs');

const dc = chain.do(6);

dc('user', null, { name: 'Marcus Aurelius' });
fs.readFile('HISTORY.md', (err, data) => dc.collect('history', err, data));
fs.readFile('README.md', dc.callback('readme'));
fs.readFile('README.md', dc('readme'));
dc.take('readme', fs.readFile, 'README.md');
setTimeout(() => dc.pick('timer', { date: new Date() }), 1000);

Run tests

npm test

License & Contributors

Copyright (c) 2013-2023 do contributors. See github for full contributors list. Do is MIT licensed.

changelog

0.4.0

  • Revert fix introduced in 0.2.0, instead provide documentation and a way how to avoid such issues. Using nextTick causes loosing stack traces and is not the right way to fix this.

0.3.0

  • Implement Do#complete
  • Make error/success callbacks optional if complete is used

0.2.0

  • Fix sync callbacks issue, more info in Do#done api description.

0.1.0

  • Ensured success callback can be triggered only once.