UNPKG

@klayr/codec

Version:

Implementation of decoder and encoder using Klayr JSON schema according to the Klayr protocol

12 lines 576 B
"use strict"; 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