Installations
npm install @duzun/async-series
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
17.1.0
NPM Version
8.1.2
Score
71.1
Supply Chain
98.8
Quality
75.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (71.88%)
TypeScript (28.12%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
duzun
Download Statistics
Total Downloads
1,828
Last Day
2
Last Week
4
Last Month
47
Last Year
160
GitHub Statistics
1 Stars
20 Commits
2 Watching
3 Branches
1 Contributors
Bundle Size
797.00 B
Minified
365.00 B
Minified + Gzipped
Package Meta Information
Latest Version
1.0.4-ts
Package Id
@duzun/async-series@1.0.4-ts
Unpacked Size
24.29 kB
Size
5.42 kB
File Count
10
NPM Version
8.1.2
Node Version
17.1.0
Total Downloads
Cumulative downloads
Total Downloads
1,828
Last day
100%
2
Compared to previous day
Last week
-86.7%
4
Compared to previous week
Last month
327.3%
47
Compared to previous month
Last year
-71.6%
160
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
asyncSeries.js
![codecov](https://codecov.io/gh/duzun/asyncSeries.js/branch/master/graph/badge.svg)
Asynchronously process a list of items consecutively.
Even though the processing is asynchronous, it is never done in parallel.
Install
1npm i -S @duzun/async-series
Import or require
This library can be included either as an ESM or UMD.
ESM
1import { 2 forEach as eachSeries, 3 map as mapSeries, 4 reduce as reduceSeries 5} from '@duzun/async-series';
CommonJS
1const { 2 forEach: eachSeries, 3 map : mapSeries, 4 reduce : reduceSeries, 5} = require('@duzun/async-series');
AMD
1require('https://unpkg.com/@duzun/async-series', (asyncSeries) => { 2 const { 3 forEach: eachSeries, 4 map : mapSeries, 5 reduce : reduceSeries, 6 } = asyncSeries; 7 8 // ... 9});
Browser
1<script src="https://unpkg.com/@duzun/async-series"></script> 2<script> 3const { 4 forEach: eachSeries, 5 map : mapSeries, 6 reduce : reduceSeries, 7} = asyncSeries; 8</script>
Usage by example
forEach(array, iteratee)
Where [async ]iteratee(value, index, array)
Process file contents of a directory, asynchronously & consecutively.
1const fs = require('mz/fs'); 2const { forEach: eachSeries } = require('@duzun/async-series'); 3 4(async () => { 5 let files = await fs.readdir('.'); 6 let results = await eachSeries(files, async (filename, idx) => { 7 if((await fs.stat(filename)).isDirectory()) return; 8 let contents = await fs.readFile(filename); 9 10 // Do some heavy processing here... 11 }); 12})();
map(array, iteratee[, firstValue])
Where [async ]iteratee(value, index, array)
Get file contents of a directory, asynchronously & consecutively;
1const fs = require('mz/fs'); 2const { map: mapSeries } = require('@duzun/async-series'); 3 4(async () => { 5 let files = await fs.readdir('.'); 6 let contents = await mapSeries(files, async (filename, idx) => { 7 if((await fs.stat(filename)).isDirectory()) return; 8 return fs.readFile(filename, 'utf8'); 9 }); 10 contents = contents.filter((x) => x); 11})();
reduce(array, reducer[, initialValue])
Where [async ]reducer(accumulator, currentValue, index, array)
Calculate file sizes in a directory, asynchronously & consecutively.
1const fs = require('mz/fs'); 2const { reduce: reduceSeries } = require('@duzun/async-series'); 3 4(async () => { 5 let files = await fs.readdir('.'); 6 let size = await reduceSeries(files, async (size, filename, idx) => { 7 let stats = await fs.stat(filename); 8 if(stats.isDirectory()) return size; 9 return size + stats.size; 10 }, 0); 11 12 console.log('size: ', size); 13})(); 14
Why?
Why not? :)
I know, there is a great library Async.js, which already has eachSeries, mapSeries and reduce and many other functions.
This library is < 900 bytes minified, and < 500 bytes when also gzipped.
And if you include it with rollup.js, you only get the function you've imported.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
7 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.1
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More