@liskhq/lisk-codec
Version:
Implementation of decoder and encoder using Lisk JSON schema according to the Lisk protocol
14 lines • 534 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readBoolean = exports.writeBoolean = void 0;
const writeBoolean = (value) => value ? Buffer.from('01', 'hex') : Buffer.from('00', 'hex');
exports.writeBoolean = writeBoolean;
const readBoolean = (buffer, offset) => {
const val = buffer[offset];
if (val !== 0x00 && val !== 0x01) {
throw new Error('Invalid boolean bytes.');
}
return [val !== 0x00, 1];
};
exports.readBoolean = readBoolean;
//# sourceMappingURL=boolean.js.map