1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.transformToString = void 0;
|
4 | const node_stream_1 = require("node: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 | */
|
14 | function transformToString() {
|
15 | return new node_stream_1.Transform({
|
16 | objectMode: false,
|
17 | readableObjectMode: true,
|
18 | transform(chunk, _, cb) {
|
19 | // console.log(`enc: ${_}`, chunk.toString())
|
20 | cb(null, chunk.toString());
|
21 | },
|
22 | });
|
23 | }
|
24 | exports.transformToString = transformToString;
|