mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-14 07:21:30 +00:00
PSON decoder example using namespaced imports
This commit is contained in:
24
examples/pson/tests/index.js
Normal file
24
examples/pson/tests/index.js
Normal 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);
|
Reference in New Issue
Block a user