How to use the Transform function from readable-stream
Find comprehensive JavaScript readable-stream.Transform code examples handpicked from public code repositorys.
8 9 10 11 12 13 14 15 16
createTransformFunction, parseOptions, } = require('../src/pino-mozlog/index'); const options = parseOptions(process.argv.slice(2)); const mozlogTransport = new Transform({ objectMode: true, transform: createTransformFunction({ options }), });
423
520
53
+ 3 other calls in file
3 4 5 6 7 8 9 10 11 12
CSVParser.prototype = Object.create(stream.Transform.prototype, { constructor: { value: CSVParser } }); function CSVParser(options) { stream.Transform.call(this, options); this.value = ''; //<co id="callout-streams-transform-1" /> this.headers = []; this.values = [];
96
191
12
GitHub: implydata/plywood
5 6 7 8 9 10 11 12 13 14
var toArray = require('stream-to-array'); var readableStream = require('readable-stream'); var Readable = readableStream.Readable; var Writable = readableStream.Writable; var Transform = readableStream.Transform; var PassThrough = readableStream.PassThrough; var immutableClass = require('immutable-class'); var generalArraysEqual = immutableClass.generalArraysEqual;
62
380
58
163 164 165 166 167 168 169 170 171 172
- __'finish'__: - __'pipe'__: - __'unpipe'__: - __'error'__: ### stream.Transform - __'readable'__: - __'data'__: - __'end'__: - __'close'__:
46
839
48
10 11 12 13 14 15 16 17 18 19
/* istanbul ignore if */ if (shouldOptimize) { // eslint-disable-next-line global-require const { optimize } = require('svgo'); doOptimize = new Transform({ objectMode: true, transform: (file, enc, cb) => { try { const optimized = optimize(file.contents.toString(enc), {
10
113
7
+ 3 other calls in file
GitHub: peermaps/peermq
21 22 23 24 25 26 27 28 29 30
mq.addPeer(argv._[1], function (err) { if (err) console.error(err) }) } else if (argv._[0] === 'listen') { mq.listen() mq.createReadStream('unread', { live: true }).pipe(new Transform({ objectMode: true, transform: function ({ from, seq, data }, enc, next) { console.log(`MESSAGE ${from}@${seq} ${data.toString()}`) mq.archive({ from, seq }, next)
2
84
10
GitHub: rvagg/through2
64 65 66 67 68 69 70 71 72 73
return Through2 }) const obj = through2(function (options, transform, flush) { const t2 = new Transform(Object.assign({ objectMode: true, highWaterMark: 16 }, options)) t2._transform = transform if (flush) {
126
0
22
+ 3 other calls in file
10 11 12 13 14 15 16 17 18 19
// cb(null, chunk); } // } // const processStream = new MyTransform(); const processStream = Transform({ transform: (chunk, encoding, callback) => { // console.log('.'); process.stdout.write('.'); callback(null, chunk);
20
76
3
GitHub: geut/permanent-seeder
24 25 26 27 28 29 30 31 32 33
translateTime: true, ignore: 'nodeID,ns', search: !error ? 'level < `40`' : undefined // Ignore higher levels than info (30) }) const pinoPrettyTransformer = new Transform({ transform (chunk, enc, callback) { chunk .toString() .split('\n')
3
27
3
GitHub: kevva/gulp-decompress
3 4 5 6 7 8 9 10 11 12
const decompress = require('decompress'); const PluginError = require('plugin-error'); const {Transform} = require('readable-stream'); const Vinyl = require('vinyl'); module.exports = options => new Transform({ objectMode: true, async transform(file, enc, cb) { if (file.isNull()) { cb(null, file);
9
16
6
GitHub: michaelnisi/manger
153 154 155 156 157 158 159 160 161 162
const ops = []; let count = 0; pipeline( db.createKeyStream(allRanks), new Transform({ objectMode: true, transform(chunk, _enc, transformCallback) { debug('transforming key: %s', chunk); const op = new Delete(chunk);
0
5
1
10 11 12 13 14 15 16 17 18 19
} return streams } function getVerbose () { return new Transform({ writableObjectMode: true, decodeStrings: false, transform: function (data, enc, cb) { setImmediate(function () { process.stdout.write(data + '\n') })
0
3
2
+ 3 other calls in file
GitHub: lilchizh/algebra-nft
8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165
if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } } function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); Duplex.call(this, options); this._transformState = { afterTransform: afterTransform.bind(this),
0
0
1
readable-stream.call is the most popular function in readable-stream (1227 examples)