UNPKG

@liskhq/lisk-codec

Version:

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

25 lines 818 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateKey = exports.getWireType = void 0; const varint_1 = require("../varint"); const getWireType = (schemaProp) => { var _a; const dataType = (_a = schemaProp.dataType) !== null && _a !== void 0 ? _a : schemaProp.type; switch (dataType) { case 'bytes': case 'string': case 'object': case 'array': return 2; default: return 0; } }; exports.getWireType = getWireType; const generateKey = (schemaProp) => { const wireType = (0, exports.getWireType)(schemaProp); const keyAsVarInt = (0, varint_1.writeUInt32)((schemaProp.fieldNumber << 3) | wireType); return keyAsVarInt; }; exports.generateKey = generateKey; //# sourceMappingURL=key.js.map