Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 880 Bytes

README.md

File metadata and controls

31 lines (21 loc) · 880 Bytes

msgpack-numpy-js

This is a javascript companion library to msgpack-numpy. It allows serialization and deserialization of the same msgpack extension type and format to/from javascript typed arrays.

This library works in nodejs and in the browser.

APIs

import { packBinary, unpackBinary } from "msgpack-numpy-js";
import msgpack from "msgpack-lite";

var data = new Uint32Array([1, 2, 3]);

var binary = packBinary(data);
var data2 = unpackBinary(binary);

alternatively a lower level API can be used:

import { packNumpy, unpackNumpy } from "msgpack-numpy-js";
import msgpack from "msgpack-lite";

var data = new Uint32Array([1, 2, 3]);

var binary = msgpack.encode(packNumpy(data), {
    codec: msgpack.createCodec({ usemap: true, binarraybuffer: true }),
  });
var data2 = unpackNumpy(msgpack.decode(binary));