UNPKG

biner

Version:

Declarative binary data encoder / decoder.

24 lines 701 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const { isType } = require('../util'); function bool(type) { if (!isType(type)) { throw new TypeError('Argument #1 should be valid type.'); } function decode(rstream) { const context = this; const [value, bytes] = type.decode.call(context, rstream); return [Boolean(value), bytes]; } function encode(value, wstream) { const context = this; return type.encode.call(context, value ? 1 : 0, wstream); } return { encode, decode, encodingLength: type.encodingLength, }; } exports.bool = bool; //# sourceMappingURL=bool.js.map