serialize-daggy
v1.0.4
Published
Serialize daggy or object with daggy
Downloads
1,106
Readme
Currently only support taggedSum
Stringify and parse your Daggy
Install
yarn add serialize-daggy
Peer dependency on Daggy
yarn add daggy
Usage examples
import { stringify, parse } from "serialize-daggy"
import { taggedSum } from "daggy"
// example daggy type
const DaggyType = taggedSum("DaggyType", {
Yes: ["value"],
No: []
})
// obj to be serialized
const obj = {
str: "string",
num: 0,
obj: { foo: "foo" },
daggy_Yes: DaggyType.Yes("lol"),
daggy_No: DaggyType.No,
date: new Date("Thu, 28 Apr 2016 22:02:17 GMT")
}
// stringify daggy
const str = stringify(obj)
// put it back
const newObj = parse(str)