{"_id":"@artkravchenko/remotedev-serialize","_rev":"1-7917d9be1913d71083be6254464684eb","name":"@artkravchenko/remotedev-serialize","dist-tags":{"latest":"0.1.9"},"versions":{"0.1.9":{"name":"@artkravchenko/remotedev-serialize","version":"0.1.9","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/artkravchenko/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/artkravchenko/remotedev-serialize/issues"},"homepage":"https://github.com/artkravchenko/remotedev-serialize","devDependencies":{"eslint":"^2.13.1","immutable":"^3.0.0","jest":"^17.0.3"},"dependencies":{"jsan":"^3.1.13"},"_id":"@artkravchenko/remotedev-serialize@0.1.9","dist":{"shasum":"8eb63bed534a2cbd07541cfde9c3a17d8b3a035e","integrity":"sha512-sjlQOP5JOi1yef3yHK7lDVDU0DAMldO+1L+HP05u4N9Ale+49syqLR8Oe8I5JdeJEkOT5JxnPyi+MG/LEITITg==","tarball":"https://registry.npmjs.org/@artkravchenko/remotedev-serialize/-/remotedev-serialize-0.1.9.tgz","fileCount":11,"unpackedSize":7967,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYTAmCRA9TVsSAnZWagAArr8P/356rFNZkv+dRCga633g\nO/r3GnmZDZaheSAAU3wAJsUum/TgM5pB0H1K7kNSjFvt3RT2AhCg4TPOENyM\n+jT5vlo4AWV6A8VXwht7d8m1F1NHp2JKmMHvmoPAhQAaSfjJvuXK9hRwlVDB\nCflRt7YGcOjct00uf6mUgl0lxNK7X1ufmaCkRrPrzxLsfERFnWD3n5cmwhOg\nq5wiQHgZZ0ZhyKELy7FZSkO4BKlEo1r0PPwuw6lz/KOFKIDamYFuPDNhNdPm\nuxsVA4PfTuMwsKczivFTSRloEdjwhu42Bl6Ejn0pWBYP63NQuUr79Rm5scrd\nnBr9LC4C4jloOCA7ChPAQqahqVvqE5FXmWJ6r7Au3IHvPfUWo+NG8JGDSjHI\nvjttsYzB4SGL4K4BGc4cEBGstnAePs0b8PMuJ682ylod5dgCiJHC3JwConO2\nDRo4V/jgY5ddFfsWTfckgA1ezowRzEI/Pti62WucwE639oLpNdflayaLB8T9\n6fwmHmePN0ztDDiYOx6iu59+l+dW3mHzX6ywwb16HyykaD0l+q3iVOSvMnWc\nRp58Czk+T5c11hXoIaS29f4z/qg3QEJ4cc9M7TX5/cXx33xz5WxDfPEyh87m\nToS7+Dvlu9PjTqkKfqHYwhvu0+mp/8P4TlU9++aJDdBNOOCDwH2NE0XQN67U\nAr7M\r\n=HQle\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBMzILub2Y+0f5KGY8sQNqqLjuFdB4c006tKgsp+J67wIgKiC63ZW94M+UA05p4K777M51dBl7jJy8E8YqWde2PY4="}]},"maintainers":[{"name":"oopscurity","email":"kravchenkofirst@gmail.com"}],"_npmUser":{"name":"oopscurity","email":"kravchenkofirst@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/remotedev-serialize_0.1.9_1583427622413_0.5282617778273606"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-05T17:00:22.204Z","0.1.9":"2020-03-05T17:00:22.556Z","modified":"2022-04-04T15:39:31.925Z"},"maintainers":[{"name":"oopscurity","email":"kravchenkofirst@gmail.com"}],"description":"Serialize unserializable data and parse it back.","homepage":"https://github.com/artkravchenko/remotedev-serialize","keywords":["redux","devtools"],"repository":{"type":"git","url":"https://github.com/artkravchenko/remotedev-serialize.git"},"author":{"name":"Mihail Diordiev","email":"zalmoxisus@gmail.com","url":"https://github.com/zalmoxisus"},"bugs":{"url":"https://github.com/artkravchenko/remotedev-serialize/issues"},"license":"MIT","readme":"Serialize ImmutableJS data\n==============================\n\n### Installation\n\n```\nnpm install --save 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/zalmoxisus/remotedev-serialize/blob/master/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 (typeof value === 'object' && value.__serializedType__ === 'number' && value.data === 'one') {\n    return 1;\n  }\n  return defaultReviver(key, value);\n}\n\nconst { stringify, parse } =  Serialize.immutable(Immutable, null, customReplacer, customReviver);\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\n#### ES6\n\n- [x] Symbol\n- [x] Map\n- [x] Set\n- [ ] Typed Array\n\n### License\n\nMIT\n","readmeFilename":"README.md"}