Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/metarhia/do
Simplest way to manage asynchronicity
https://github.com/metarhia/do
async asynchronous await callback chain collector composition highload impress javascript js metarhia node nodejs parallel promise promisify series synchronous thenable
Last synced: 3 months ago
JSON representation
Simplest way to manage asynchronicity
- Host: GitHub
- URL: https://github.com/metarhia/do
- Owner: metarhia
- License: mit
- Created: 2013-01-30T20:44:21.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-03T22:19:07.000Z (almost 1 year ago)
- Last Synced: 2024-10-11T16:38:27.933Z (4 months ago)
- Topics: async, asynchronous, await, callback, chain, collector, composition, highload, impress, javascript, js, metarhia, node, nodejs, parallel, promise, promisify, series, synchronous, thenable
- Language: JavaScript
- Homepage: https://metarhia.com
- Size: 369 KB
- Stars: 43
- Watchers: 16
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: history.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
## "do" is the simplest way to manage asynchronicity
[![CI Status](https://github.com/metarhia/do/workflows/Testing%20CI/badge.svg)](https://github.com/metarhia/do/actions?query=workflow%3A%22Testing+CI%22+branch%3Amaster)
[![NPM Version](https://badge.fury.io/js/do.svg)](https://badge.fury.io/js/do)
[![NPM Downloads/Month](https://img.shields.io/npm/dm/do.svg)](https://www.npmjs.com/package/do)
[![NPM Downloads](https://img.shields.io/npm/dt/do.svg)](https://www.npmjs.com/package/do)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
```js
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
```js
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](https://github.com/metarhia/do/graphs/contributors).
Do is [MIT licensed](./LICENSE).