through2-asyncmap
An async-only version of through2-map
var map = var truncate = // vs. with through2:var truncate = // Then use your map:source // Additionally accepts `wantStrings` argument to convert buffers into stringsvar stripTags =
*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