UNPKG

797 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.transformToString = void 0;
4const stream_1 = require("stream");
5/**
6 * Transforms objectMode=false Buffers/strings into objectMode=true strings.
7 *
8 * Useful in this _pipeline:
9 * fs.createReadStream(inputPath),
10 * createUnzip(), // binary
11 * transformSplit(), // string chunks, but objectMode==false
12 * transformToString(), // string chunks, but objectMode==true
13 */
14function transformToString() {
15 return new stream_1.Transform({
16 objectMode: false,
17 readableObjectMode: true,
18 transform(chunk, _encoding, cb) {
19 // console.log(`enc: ${_encoding}`, chunk.toString())
20 cb(null, chunk.toString());
21 },
22 });
23}
24exports.transformToString = transformToString;