process-tunnel
Version:
32 lines (31 loc) • 1.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedWritableStream = void 0;
var Concentrate = require('concentrate');
var TypedWritableStream = /** @class */ (function () {
function TypedWritableStream(channel) {
this.stream = new Concentrate();
this.stream.pipe(channel);
}
TypedWritableStream.prototype.writeType = function (type) {
this.stream.int8(type);
return this;
};
TypedWritableStream.prototype.writeCallback = function (callback) {
this.stream.string(callback, 'utf8');
};
TypedWritableStream.prototype.writeJSON = function (data) {
var result = JSON.stringify(data);
this.stream.int32(Buffer.byteLength(result, 'utf8'));
this.stream.string(result, 'utf8');
return this;
};
TypedWritableStream.prototype.flush = function () {
this.stream.flush();
};
TypedWritableStream.prototype.destroy = function () {
this.stream.destroy();
};
return TypedWritableStream;
}());
exports.TypedWritableStream = TypedWritableStream;
;