1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const stream = require("stream");
|
4 |
|
5 | let transform = new stream.Transform({ decodeStrings: false });
|
6 | transform._transform = function (chunk, _encoding, next) {
|
7 | let data = chunk;
|
8 | if (this._lastLineData)
|
9 | data = this._lastLineData + data;
|
10 | let lines = data.split('\n');
|
11 | this._lastLineData = lines.splice(lines.length - 1, 1)[0];
|
12 | lines.forEach(this.push.bind(this));
|
13 | next();
|
14 | };
|
15 | transform._flush = function (done) {
|
16 | if (this._lastLineData)
|
17 | this.push(this._lastLineData);
|
18 | this._lastLineData = null;
|
19 | done();
|
20 | };
|
21 | exports.default = transform;
|