1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | if (typeof b !== "function" && b !== null)
|
11 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12 | extendStatics(d, b);
|
13 | function __() { this.constructor = d; }
|
14 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15 | };
|
16 | })();
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.WritableStream = void 0;
|
19 | var Parser_js_1 = require("./Parser.js");
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | var node_stream_1 = require("node:stream");
|
25 | var node_string_decoder_1 = require("node:string_decoder");
|
26 |
|
27 | function isBuffer(_chunk, encoding) {
|
28 | return encoding === "buffer";
|
29 | }
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | var WritableStream = (function (_super) {
|
36 | __extends(WritableStream, _super);
|
37 | function WritableStream(cbs, options) {
|
38 | var _this = _super.call(this, { decodeStrings: false }) || this;
|
39 | _this._decoder = new node_string_decoder_1.StringDecoder();
|
40 | _this._parser = new Parser_js_1.Parser(cbs, options);
|
41 | return _this;
|
42 | }
|
43 | WritableStream.prototype._write = function (chunk, encoding, callback) {
|
44 | this._parser.write(isBuffer(chunk, encoding) ? this._decoder.write(chunk) : chunk);
|
45 | callback();
|
46 | };
|
47 | WritableStream.prototype._final = function (callback) {
|
48 | this._parser.end(this._decoder.end());
|
49 | callback();
|
50 | };
|
51 | return WritableStream;
|
52 | }(node_stream_1.Writable));
|
53 | exports.WritableStream = WritableStream;
|
54 |
|
\ | No newline at end of file |