This module could not have been built without this awesome blog post series.
npm install marshal
var Marshal = require('marshal'); var m = new Marshal('0408220a68656c6c6f', 'hex'); console.log(m.parsed); // 'hello'
Decode a Rails cookie
This library was purpose-built for sharing a Rails cookie with an Express session.
See instore/rails-cookie-parser for an example.
Features / Limitations
- floats (thank you @tgriesser!)
- bignums (bignums are broken after v0.2.0, if you need bignum support please use v0.2.0)
- raw strings
- symbol links
- object links
- IVARs (encoded strings, regular expressions are not supported)
- regular expressions
- others (see the RubySpec Marshal spec)
From what I can tell, positive integers are unsigned and negative integers are signed. Thus, positive integers have twice the range as negative integers.
The bignum base conversion algorithm was adapted from MikeMcl/decimal.js which is copyright Michael Mclaughlin.