Skip to content

Instantly share code, notes, and snippets.

@zew13
Created October 25, 2023 05:12
Show Gist options
  • Save zew13/ff922162642f693328e71b87c876f936 to your computer and use it in GitHub Desktop.
Save zew13/ff922162642f693328e71b87c876f936 to your computer and use it in GitHub Desktop.
#!/usr/bin/env -S node --import=@3-/jsext --trace-uncaught --expose-gc --unhandled-rejections=strict
var bf, deserialize, fury, obj, result, serialize;
import {
Type,
default as Fury
} from '@furyjs/fury';
console.log(Type);
fury = new Fury.default({
refTracking: true
});
({serialize, deserialize} = fury.registerSerializer(Type.object("example.foo", {
foo: Type.any(),
bar: Type.any(),
map: Type.map(Type.any(), Type.any()),
set: Type.set(Type.any()),
list: Type.array(Type.any()),
binary: Type.binary()
})));
obj = {
foo: "123",
bar: 123,
map: new Map([["hello", 1], ["world", 2]]),
set: new Set([1, 2, "123"]),
list: ["123", 123, true],
binary: new Uint8Array([1, 2, 3])
};
bf = serialize(obj);
result = deserialize(bf);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment