UNPKG

@betit/orion

Version:

Pluggable microservice framework

30 lines (29 loc) 706 B
"use strict"; const msgpack = require('msgpack-lite'); const utils_1 = require('../utils'); const debug = utils_1.debugLog('orion:codec:msgpack'); /** * MessagePack, an efficient binary serialization format. */ class MsgPackCodec { constructor() { this.encoding = null; this.contentType = 'application/msgpack'; } /** * Encode data. */ encode(data) { debug('encode'); return msgpack.encode(data); } /** * Decode data. */ decode(data) { debug('decode'); return msgpack.decode(Buffer.from(data, 'binary')); } } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = MsgPackCodec;