19 lines
770 B
JavaScript
19 lines
770 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.encode = exports.getChunkHeader = void 0;
|
|
const constants_1 = require("./constants");
|
|
const getChunkHeader = (_data) => Buffer.alloc(0);
|
|
exports.getChunkHeader = getChunkHeader;
|
|
const encode = (data, options) => {
|
|
const { messageType } = options;
|
|
if (typeof messageType === 'string') {
|
|
throw new Error(`Unsupported message type ${messageType}`);
|
|
}
|
|
const encodedBuffer = Buffer.alloc(constants_1.HEADER_SIZE + data.length);
|
|
encodedBuffer.writeUInt16BE(messageType);
|
|
encodedBuffer.writeUInt32BE(data.length, 2);
|
|
data.copy(encodedBuffer, constants_1.HEADER_SIZE);
|
|
return encodedBuffer;
|
|
};
|
|
exports.encode = encode;
|
|
//# sourceMappingURL=encode.js.map
|