PSON decoder example using namespaced imports

This commit is contained in:
dcodeIO
2017-12-30 05:11:58 +01:00
parent c67f87a988
commit 2888ba14ad
41 changed files with 1283 additions and 336 deletions

View File

@ -0,0 +1,24 @@
var Long = require("long");
var psonJS = require("pson");
var psonWASM = require("..");
// encode in JS
var buf = new psonJS.Encoder().encode({
emptyObject: {},
emptyArray: [],
emptyString: "",
object: {
aSmallInt: 42,
anInt: 9000,
aLong: Long.MIN_VALUE.add(1)
},
array: [
0.25, // fits into float
0.1 // always a double
],
binary: Buffer.from([1, 2, 3])
}).toBuffer();
// decode in WASM
psonWASM.decode(buf);