UNPKG

876 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _stream = require("stream");
9
10function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
12/*
13 * "Taps" into the contents of a flowing stream, yielding chunks to the passed
14 * callback. Continues to pass data chunks down the stream.
15 */
16class TapStream extends _stream.Transform {
17 constructor(tap, options) {
18 super({ ...options
19 });
20
21 _defineProperty(this, "_tap", void 0);
22
23 this._tap = tap;
24 }
25
26 _transform(chunk, encoding, callback) {
27 try {
28 this._tap(Buffer.from(chunk));
29
30 callback(null, chunk);
31 } catch (err) {
32 callback(err);
33 }
34 }
35
36}
37
38exports.default = TapStream;
\No newline at end of file