ncase / loopy

A tool for thinking in systems
http://ncase.me/loopy/
Creative Commons Zero v1.0 Universal
1.62k stars 212 forks source link

Smaller URL : binary gzip compressed data storage, base64 wrapped in the url #25

Closed 1000i100 closed 4 years ago

1000i100 commented 4 years ago

Right now, loopy data are stored in json with a serialize / deserialize process. I think we can do better to store big system in small url (even without url reducer)

Here is the binary data scheme :

this stored in binary then gzipped (or lzma) then b64 for URL and the string part : string are dedup and sorted by size ASC then stored in a json array escaped for url. the index of this array is used in the binary part to target strings.

the parser try to rebuild and allow the json array string to be erroneous/partial, in this case, it add at the end "] or ] and retry parsing. the missing string in index a replaced by ? so the graph can be used with less text but still usable.

What's your feeling about this ?

PS : this change can be done with compatibility for actual json storage by detecting the url scheme post ?char

PS2: embed setting can be stored in globalOptions, same for autoplay if not handled as special node.

1000i100 commented 4 years ago

Done in #20 See https://github.com/1000i100/loopy/blob/gh-pages/2/js/persist.js and https://github.com/1000i100/loopy/blob/gh-pages/2/js/persist.test.js to understand how it's done.