Installations
npm install through2-asyncmap
Developer Guide
Typescript
No
Module System
CommonJS
NPM Version
1.4.9
Score
68.6
Supply Chain
97
Quality
74.5
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
brycebaril
Download Statistics
Total Downloads
92,134
Last Day
145
Last Week
538
Last Month
4,146
Last Year
44,379
GitHub Statistics
2 Stars
6 Commits
2 Watching
1 Branches
1 Contributors
Bundle Size
16.80 kB
Minified
4.95 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.0
Package Id
through2-asyncmap@1.1.0
Size
2.73 kB
NPM Version
1.4.9
Total Downloads
Cumulative downloads
Total Downloads
92,134
Last day
1,015.4%
145
Compared to previous day
Last week
-50.6%
538
Compared to previous week
Last month
-0.9%
4,146
Compared to previous month
Last year
131.3%
44,379
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
through2-asyncmap
An async-only version of through2-map
1 2var map = require("through2-asyncmap") 3 4var truncate = map(function (chunk, callback) { 5 setImmediate(function () { 6 callback(null, chunk.slice(0, 10)) 7 }) 8}) 9 10// vs. with through2: 11var truncate = through2(function (chunk, encoding, callback) { 12 setImmediate(function () { 13 this.push(chunk.slice(0, 10)) 14 return callback() 15 }) 16}) 17 18// Then use your map: 19source.pipe(truncate).pipe(sink) 20 21// Additionally accepts `wantStrings` argument to convert buffers into strings 22var stripTags = map({wantStrings: true}, function (str, next) { 23 // OMG don't actually use this 24 setImmediate(function () {next(null, str.replace(/<.*?>/g, ""))} 25}) 26 27// Works like `Array.prototype.map` meaning you can specify a function that 28// takes up to two* arguments: fn(chunk, index) 29var spaceout = map({wantStrings: true}, function (chunk, index, callback) { 30 setImmediate(functio () { 31 callback(null, (index % 2 == 0) ? chunk + "\n\n" : chunk) 32 }) 33}) 34 35// vs. with through2: 36var spaceout = through2(function (chunk, encoding, callback) { 37 if (this.index == undefined) { 38 this.index = 0 39 } 40 setImmediate(function () { 41 var buf = (this.index++ % 2 == 0) ? Buffer.concat(chunk, new Buffer("\n\n")) : chunk 42 this.push(buf) 43 return callback() 44 }) 45}) 46
*Differences from Array.prototype.map
:
- Cannot insert
null
elements into the stream without aborting. - No third
array
callback argument. That would require realizing the entire stream, which is generally counter-productive to stream operations. Array.prototype.map
doesn't modify the source Array, which is somewhat nonsensical when applied to streams.
API
require("through2-asyncmap")([options,] fn)
Create a stream.Transform
instance that will call fn(chunk, [index,] callback)
on each stream segment.
callback
is expected to return two arguments: callback(error, replacementChunk)
and will replace the provided chunk with replacementChunk
If error
is true, it will emit that error on the stream.
var Tx = require("through2-asyncmap").ctor([options,] fn)
Create a reusable stream.Transform
TYPE that can be called via new Tx
or Tx()
to create an instance.
require("through2-asyncmap").obj([options,] fn)
Create a through2-asyncmap
instance that defaults to objectMode: true
.
require("through2-asyncmap").objCtor([options,] fn)
Just like ctor, but with objectMode: true
defaulting to true.
Options
- wantStrings: Automatically call chunk.toString() for the super lazy.
- all other through2 options
LICENSE
MIT
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/6 approved changesets -- score normalized to 0
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
3
/10
Last Scanned on 2025-01-27
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