Merge pull request #21236 from TimBeyer/fix-msgpack-lite-options

fix(msgpack-lite): fix msgpack-lite option parameters
This commit is contained in:
Daniel Rosenwasser
2017-11-04 01:27:05 -07:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ export interface CodecOptions {
* @see https://github.com/kawanet/msgpack-lite#compatibility-mode
* @default false
*/
raw?: boolean;
useraw?: boolean;
/**
* It decodes msgpack's int64/uint64 formats with int64-buffer object.
* int64-buffer is a cutom integer type with 64 bits of precision instead
@@ -140,8 +140,14 @@ export interface CodecOptions {
binarraybuffer?: boolean;
/**
* It returns Uint8Array object when encoding, instead of Buffer object.
* @default false
*/
uint8array?: boolean;
/**
* It uses the global JavaScript Map type, if available, to unpack MessagePack map elements.
* @default false
*/
usemap?: boolean;
}
export interface EncoderOptions {

View File

@@ -9,6 +9,18 @@ function encodingAndDecoding() {
const data = msgpack.decode(buffer); // => {"foo": "bar"}
}
function customCodec() {
msgpack.createCodec({
preset: true,
safe: true,
useraw: true,
int64: true,
binarraybuffer: true,
uint8array: true,
usemap: true
});
}
// https://github.com/kawanet/msgpack-lite#writing-to-messagepack-stream
function writingToStream() {
const fs = require("fs");