How to use msgpack-lite - 10 common examples

To help you get started, we’ve selected a few msgpack-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holochain / n3h / lib / hackmode / realmode.js View on Github external
async _p2pSend (peerAddress, obj) {
    // log.t(this.me() + ' >>> ' + this.nick(peerAddress) + ' - ' + obj.type)
    return this._p2p.publishReliable(
      [peerAddress],
      msgpack.encode(obj).toString('base64')
    )
  }
github holochain / n3h / lib / hackmode / realmode.js View on Github external
async _p2pSendAll (obj) {
    // log.t(this.me() + ' >>> ' + this._peerList + ' - ' + obj.type)
    return this._p2p.publishReliable(
      this._peerList,
      msgpack.encode(obj).toString('base64')
    )
  }
github holochain / n3h / packages / n3h-mod-message-mosocket / examples / c3hat / c3hat.js View on Github external
const ipcMsg = async (type, data) => {
    const resp = await client.call(
      msgpack.encode({ type, data }))
    if (!resp) {
      console.error('bad ipc response', resp)
      process.exit(1)
    }
    if (resp.byteLength) {
      return msgpack.decode(resp)
    }
  }
github jwkvam / bowtie / bowtie / src / textbox.jsx View on Github external
onPressEnter = value => {
        this.setState({ value: value.target.value });
        storeState(this.props.uuid, this.state, { value: value.target.value });
        this.props.socket.emit(this.props.uuid + '#enter', msgpack.encode(value.target.value));
    };
github allegro / node-worker-nodes / lib / worker / transport.js View on Github external
send(message) {
        const serializedMessage = msgpack.encode(message);
        const header = new Uint32Array([ serializedMessage.byteLength ]);

        this.pipe.write(Buffer.from(header.buffer));
        this.pipe.write(serializedMessage);
    }
}
github tinkerhub / tinkerhub / lib / net / tcp.js View on Github external
write(type, payload) {
		const data = msgpack.encode([ String(type), payload ]);
		this.socket.write(data);
	}
github glacambre / firenvim / src / nvimproc / Stdin.ts View on Github external
public write(reqId: number, method: string, args: any[]) {
        const req = [0, reqId, method, args];
        const encoded = msgpack.encode(req);
        this.socket.send(encoded);
    }
github colyseus / colyseus / lib / room.js View on Github external
getEncodedState () {

    return msgpack.encode( utils.toJSON( this.state ) )

  }
github SocketCluster / sc-codec-min-bin / index.js View on Github external
module.exports.decode = function (str) {
  str = new Uint8Array(str);
  var object = msgpack.decode(str, options);
  if (Array.isArray(object)) {
    var len = object.length;
    for (var i = 0; i < len; i++) {
      decompressSinglePacket(object[i]);
    }
  } else {
    decompressSinglePacket(object);
  }
  return object;
};
github SocketCluster / sc-codec-min-bin / sc-codec-min-bin.js View on Github external
module.exports.decode = function (str) {
  str = new Uint8Array(str);
  var object = msgpack.decode(str, options);
  if (Array.isArray(object)) {
    var len = object.length;
    for (var i = 0; i < len; i++) {
      decompressSinglePacket(object[i]);
    }
  } else {
    decompressSinglePacket(object);
  }
  return object;
};

msgpack-lite

Fast Pure JavaScript MessagePack Encoder and Decoder

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis

Popular msgpack-lite functions