cryonic
Version:
Easily pickle/serialize/freeze/store and re-hydrate complex JavaScript objects (including Functions)
14 lines (10 loc) • 415 B
JavaScript
var Cryo = require('../lib/cryo');
var userList = [{ name: 'Abe' }, { name: 'Bob' }, { name: 'Carl' }];
var state = {
users: userList,
activeUser: userList[1]
};
var withJSON = JSON.parse(JSON.stringify(state));
console.log(withJSON.activeUser === withJSON.users[1]); // false
var withCryo = Cryo.parse(Cryo.stringify(state));
console.log(withCryo.activeUser === withCryo.users[1]); // true