{"name":"remotedev-serialize","version":"0.1.0-alpha","description":"Serialize unserializable data and parse it back.","main":"index.js","scripts":{"lint":"eslint src test","test":"jest --no-cache","prepublish":"npm run lint && npm run test"},"repository":{"type":"git","url":"https://github.com/zalmoxisus/remotedev-serialize.git"},"keywords":["redux","devtools"],"author":{"name":"Mihail Diordiev","email":"zalmoxisus@gmail.com","url":"https://github.com/zalmoxisus"},"license":"MIT","bugs":{"url":"https://github.com/zalmoxisus/remotedev-serialize/issues"},"homepage":"https://github.com/zalmoxisus/remotedev-serialize","devDependencies":{"eslint":"^2.13.1","immutable":"^3.0.0","jest":"^17.0.3"},"dependencies":{"jsan":"^3.1.0"},"gitHead":"e9733d0fb84560461707b258f19daa7e672347b7","_id":"remotedev-serialize@0.1.0-alpha","_shasum":"4abede822001bc4979ccece4bb2ea829b6923188","_from":".","_npmVersion":"3.7.3","_nodeVersion":"5.8.0","_npmUser":{"name":"zalmoxisus","email":"zalmoxisus@gmail.com"},"dist":{"shasum":"4abede822001bc4979ccece4bb2ea829b6923188","tarball":"http://registry-npm.ywwl.com/remotedev-serialize/download/remotedev-serialize-0.1.0-alpha.tgz","integrity":"sha512-fEh33Vsszd9Kqa/OZOa1HiQeD9R/N9yO/je5ZSrfYlGCcWoGGWNkmkMZm0pm8dx3ljbmhSWiWBMrPM+eYMG0jA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGo2TEC0ArggBE/H2QSJvH9zw5CdXcHYqFal86qtk6I0AiB5afv+zJaXyWUlmRYt6V23dSALvyTvaC5fmvctpapsSA=="}],"size":1550,"noattachment":false,"key":"/remotedev-serialize/-/remotedev-serialize-0.1.0-alpha.tgz"},"maintainers":[{"name":"zalmoxisus","email":"zalmoxisus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/remotedev-serialize-0.1.0-alpha.tgz_1484041626164_0.9099691573064774"},"directories":{},"readme":"# Serialize ImmutableJS data\n\n### Installation\n\n```\nyarn add remotedev-serialize\n```\n\n### Usage with ImmutableJS data structures\n\nJust pass the Immutable library to our class:\n\n```js\nimport Immutable from 'immutable';\nimport Serialize from 'remotedev-serialize';\nconst { stringify, parse } = Serialize.immutable(Immutable);\n\nconst data = Immutable.fromJS({ foo: 'bar', baz: { qux: 42 } });\nconst serialized = stringify(data);\nconsole.log(serialized);\n// {\"data\":{\"foo\":\"bar\",\"baz\":{\"data\":{\"qux\":42},\"__serializedType__\":\"ImmutableMap\"}},\"__serializedType__\":\"ImmutableMap\"}\nconst parsed = parse(serialized);\nconsole.log(Immutable.is(parsed, data));\n// true\n```\n\nSee [the tests](https://github.com/reduxjs/remote-devtools/blob/master/packages/remotedev-serialize/test/immutable.spec.js) for more examples of usage.\n\n### Usage with ImmutableJS Record classes\n\nTo parse a Record class back, you need to specify a reference to it:\n\n```js\nimport Immutable from 'immutable';\nimport Serialize from 'remotedev-serialize';\n\nconst ABRecord = Immutable.Record({ a: 1, b: 2 });\nconst { stringify, parse } = Serialize.immutable(Immutable, [ABRecord]);\n\nconst myRecord = new ABRecord({ b: 3 });\nconst serialized = stringify(myRecord);\nconsole.log(serialized);\n// {\"data\":{\"a\":1,\"b\":3},\"__serializedType__\":\"ImmutableRecord\",\"__serializedRef__\":0}\nconst parsed = parse(serialized);\nconsole.log(Immutable.is(parsed, myRecord));\n// true\n```\n\n### Passing custom serialization functions\n\nYou can pass custom replacer and reviver functions to Serialize:\n\n```js\nimport Immutable from 'immutable';\nimport Serialize from 'remotedev-serialize';\n\nfunction customReplacer(key, value, defaultReplacer) {\n  if (value === 1) {\n    return { data: 'one', __serializedType__: 'number' };\n  }\n  return defaultReplacer(key, value);\n}\n\nfunction customReviver(key, value, defaultReviver) {\n  if (\n    typeof value === 'object' &&\n    value.__serializedType__ === 'number' &&\n    value.data === 'one'\n  ) {\n    return 1;\n  }\n  return defaultReviver(key, value);\n}\n\nconst { stringify, parse } = Serialize.immutable(\n  Immutable,\n  null,\n  customReplacer,\n  customReviver\n);\n\nconst map = Immutable.Map({ a: 1, b: 2 });\nconst serialized = stringify(map);\nconsole.log(serialized);\n// {\"data\":{\"a\":{\"data\":\"one\",\"__serializedType__\":\"number\"},\"b\":2},\"__serializedType__\":\"ImmutableMap\"}\nconst parsed = parse(serialized);\nconsole.log(Immutable.is(parsed, map));\n// true\n```\n\n### Supported\n\n#### ImutableJS\n\n- [x] Record\n- [x] Range\n- [x] Repeat\n- [x] Map\n- [x] OrderedMap\n- [x] List\n- [x] Set\n- [x] OrderedSet\n- [x] Seq\n- [x] Stack\n\n#### ES6\n\n- [x] Symbol\n- [x] Map\n- [x] Set\n- [ ] Typed Array\n\n### License\n\nMIT\n","publish_time":1484041628163,"_cnpm_publish_time":1484041628163,"dist-tags":{"latest":"0.1.9"}}