@radixdlt/tx-parser
Version:
Parsing of Radix Engine transactions and instructions
21 lines • 744 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bytes = void 0;
const LENGTH_BYTES = 2;
const fromBufferReader = (bufferReader) => bufferReader
.readNextBuffer(LENGTH_BYTES)
.map(b => b.readUInt16BE(0))
.andThen((length) => bufferReader.readNextBuffer(length).map(data => ({
length,
data,
})))
.map(partial => {
const lengthBuf = Buffer.alloc(LENGTH_BYTES);
lengthBuf.writeUInt16BE(partial.length);
const buffer = Buffer.concat([lengthBuf, partial.data]);
return Object.assign(Object.assign({}, partial), { toBuffer: () => buffer, toString: () => `0x${partial.data.toString('hex')}` });
});
exports.Bytes = {
fromBufferReader,
};
//# sourceMappingURL=bytes.js.map