A serialization library that supports abstract values
JavaScript Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
serialization-test.waul.sdoc
serialization.js
serialization.waul.sdoc
t

README

Mediocre serialization for Javascript.
This library is basically a port of Rather Insane Serialization to Caterwaul.
It serializes things using stateful streams, which construct references for
opaque objects and can later resolve those references. For example:

d = document.createElement('div')
stream = caterwaul.serialization()
s = stream({dom_node: d})
decoded = stream.decode(s)
decoded.dom_node === d          // returns true

It uses this technique when encoding objects whose prototypes are unknown.

NOTE! This library doesn't serialize directly to strings. Instead, it produces
JSON objects that you can serialize using any JSON library (or convert them to
XML, or whatever). It's implemented this way (1) because I'm lazy, and (2)
because a native JSON implementation is probably faster than anything I would
be willing to implement here.