@liskhq/lisk-codec
Version:
Implementation of decoder and encoder using Lisk JSON schema according to the Lisk protocol
12 lines • 576 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readBytes = exports.writeBytes = void 0;
const varint_1 = require("./varint");
const writeBytes = (bytes) => Buffer.concat([(0, varint_1.writeUInt32)(bytes.length), bytes]);
exports.writeBytes = writeBytes;
const readBytes = (buffer, offset) => {
const [byteLength, keySize] = (0, varint_1.readUInt32)(buffer, offset);
return [buffer.subarray(offset + keySize, offset + keySize + byteLength), byteLength + keySize];
};
exports.readBytes = readBytes;
//# sourceMappingURL=bytes.js.map