Gathering detailed insights and metrics for through2-asyncmap
Gathering detailed insights and metrics for through2-asyncmap
npm install through2-asyncmap
Typescript
Module System
NPM Version
68.6
Supply Chain
97
Quality
74.5
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
92,134
Last Day
145
Last Week
538
Last Month
4,146
Last Year
44,379
2 Stars
6 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
through2-asyncmap@1.1.0
Size
2.73 kB
NPM Version
1.4.9
Cumulative downloads
Total Downloads
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
3
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
:
null
elements into the stream without aborting.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.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.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
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