{"version":"1.7.3-dont-mutate-serialize","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","module":"dist/esm/index.js","engines":{"node":">=10"},"scripts":{"build":"yarn build:cjs && yarn build:esm","build:cjs":"tsc","build:esm":"tsc --module es2015 --outDir dist/esm","test":"tsdx test --notify --verbose","lint":"tsdx lint","prepack":"yarn build","prepare":"husky install"},"importSort":{".ts":{"style":"module"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"name":"superjson","author":{"name":"Simon Knott","email":"info@simonknott.de","url":"https://simonknott.de"},"contributors":[{"name":"Dylan Brookes","email":"dylan@brookes.net","url":"https://github.com/merelinguist"},{"name":"Brandon Bayer","email":"b@bayer.w","url":"https://twitter.com/flybayer"}],"repository":{"type":"git","url":"https://github.com/blitz-js/superjson"},"devDependencies":{"@types/debug":"^4.1.5","@types/lodash":"^4.14.168","@types/lodash.clonedeep":"^4.5.6","@types/mongodb":"^3.6.7","benchmark":"^2.1.4","eslint-plugin-es5":"^1.5.0","husky":"^5.0.9","mongodb":"^3.6.4","tsdx":"^0.14.1","typescript":"^4.1.5"},"dependencies":{"debug":"^4.3.1","lodash.clonedeep":"^4.5.0"},"resolutions":{"**/@typescript-eslint/eslint-plugin":"^4.11.1","**/@typescript-eslint/parser":"^4.11.1","**/jest":"^26.6.3","**/ts-jest":"^26.4.4"},"readmeFilename":"README.md","readme":"<p align=\"center\">\n  <img alt=\"superjson\" src=\"./docs/superjson.png\" width=\"300\" />\n</p>\n\n<p align=\"center\">\n  Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.\n</p>\n\n<p align=\"center\">\n  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n<a href=\"#contributors\"><img src=\"https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square\" alt=\"All Contributors\"/></a>\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n  <a href=\"https://www.npmjs.com/package/superjson\">\n    <img alt=\"npm\" src=\"https://img.shields.io/npm/v/superjson\" />\n  </a>\n  <a href=\"https://lgtm.com/projects/g/blitz-js/superjson/context:javascript\">\n    <img\n      alt=\"Language grade: JavaScript\"\n      src=\"https://img.shields.io/lgtm/grade/javascript/g/blitz-js/superjson.svg?logo=lgtm&logoWidth=18\"\n    />\n  </a>\n\n  <a href=\"https://github.com/blitz-js/superjson/actions\">\n    <img\n      alt=\"CI\"\n      src=\"https://github.com/blitz-js/superjson/workflows/CI/badge.svg\"\n    />\n  </a>\n</p>\n\n## Key features\n\n- 🍱 Reliable serialization and deserialization\n- 🔐 Type safety with autocompletion\n- 🐾 Negligible runtime footprint\n- 💫 Framework agnostic\n- 🛠 Perfect fix for Next.js's serialisation limitations in `getServerSideProps` and `getInitialProps`\n\n## Backstory\n\nAt [Blitz](https://github.com/blitz-js/blitz), we have struggled with the limitations of JSON. We often find ourselves working with `Date`, `Map`, `Set` or `BigInt`, but `JSON.stringify` doesn't support any of them without going through the hassle of converting manually!\n\nSuperjson solves these issues by providing a thin wrapper over `JSON.stringify` and `JSON.parse`.\n\n## Getting started\n\nInstall the library with your package manager of choice, e.g.:\n\n```\nyarn add superjson\n```\n\n## Basic Usage\n\nThe easiest way to use Superjson is with its `stringify` and `parse` functions. If you know how to use `JSON.stringify`, you already know Superjson!\n\nEasily stringify any expression you’d like:\n\n```js\nimport superjson from 'superjson';\n\nconst jsonString = superjson.stringify({ date: new Date(0) });\n\n// jsonString === '{\"json\":{\"date\":\"1970-01-01T00:00:00.000Z\"},\"meta\":{\"values\":{date:\"Date\"}}}'\n```\n\nAnd parse your JSON like so:\n\n```js\nconst object = superjson.parse<{ date: Date }>(jsonString);\n\n// object === { date: new Date(0) }\n```\n\n## Advanced Usage\n\nFor cases where you want lower level access to the `json` and `meta` data in the output, you can use the `serialize` and `deserialize` functions.\n\nOne great use case for this is where you have an API that you want to be JSON compatible for all clients, but you still also want to transmit the meta data so clients can use superjson to fully deserialize it.\n\nFor example:\n\n```js\nconst object = {\n  normal: 'string',\n  timestamp: new Date(),\n  test: /superjson/,\n};\n\nconst { json, meta } = superjson.serialize(object);\n\n/*\njson = {\n  normal: 'string',\n  timestamp: \"2020-06-20T04:56:50.293Z\",\n  test: \"/blitz/\",\n};\n\n// note that `normal` is not included here; `meta` only has special cases\nmeta = {\n  timestamp: ['date'],\n  test: ['regexp'],\n};\n*/\n```\n\n## Using with Next.js\n\nThe `getServerSideProps`, `getInitialProps`, and `getStaticProps` data hooks provided by Next.js do not allow you to transmit Javascript objects like Dates. It will error unless you convert Dates to strings, etc.\n\nThankfully, Superjson is a perfect tool to bypass that limitation!\n\nInstall the library with your package manager of choice, e.g.:\n\n```sh\nyarn add -D babel-plugin-superjson-next\n```\n\nAdd the plugin to your .babelrc. If you don't have one, create it.\n\n```js\n{\n  \"presets\": [\"next/babel\"],\n  \"plugins\": [\n    ...\n    \"superjson-next\" // 👈\n  ]\n}\n```\n\nDone! Now you can safely use all JS datatypes in your `getServerSideProps` / etc. .\n\n## API\n\n### serialize\n\nSerializes any JavaScript value into a JSON-compatible object.\n\n#### Examples\n\n```js\nconst object = {\n  normal: 'string',\n  timestamp: new Date(),\n  test: /superjson/,\n};\n\nconst { json, meta } = serialize(object);\n```\n\nReturns **`json` and `meta`, both JSON-compatible values.**\n\n## deserialize\n\nDeserializes the output of Superjson back into your original value.\n\n#### Examples\n\n```js\nconst { json, meta } = serialize(object);\n\ndeserialize({ json, meta });\n```\n\nReturns **`your original value`**.\n\n### stringify\n\nSerializes and then stringifies your JavaScript value.\n\n#### Examples\n\n```js\nconst object = {\n  normal: 'string',\n  timestamp: new Date(),\n  test: /superjson/,\n};\n\nconst jsonString = stringify(object);\n```\n\nReturns **`string`**.\n\n### parse\n\nParses and then deserializes the JSON string returned by `stringify`.\n\n#### Examples\n\n```js\nconst jsonString = stringify(object);\n\nparse(jsonString);\n```\n\nReturns **`string`**.\n\n---\n\nSuperjson supports many extra types which JSON does not. You can serialize all these:\n\n| type        | supported by standard JSON? | supported by Superjson? |\n| ----------- | --------------------------- | ----------------------- |\n| `string`    | ✅                           | ✅                       |\n| `number`    | ✅                           | ✅                       |\n| `boolean`   | ✅                           | ✅                       |\n| `null`      | ✅                           | ✅                       |\n| `Array`     | ✅                           | ✅                       |\n| `Object`    | ✅                           | ✅                       |\n| `undefined` | ❌                           | ✅                       |\n| `bigint`    | ❌                           | ✅                       |\n| `Date`      | ❌                           | ✅                       |\n| `RegExp`    | ❌                           | ✅                       |\n| `Set`       | ❌                           | ✅                       |\n| `Map`       | ❌                           | ✅                       |\n| `Error`     | ❌                           | ✅                       |\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"https://github.com/merelinguist\"><img src=\"https://avatars3.githubusercontent.com/u/24858006?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Dylan Brookes</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=merelinguist\" title=\"Code\">💻</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=merelinguist\" title=\"Documentation\">📖</a> <a href=\"#design-merelinguist\" title=\"Design\">🎨</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=merelinguist\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"http://simonknott.de\"><img src=\"https://avatars1.githubusercontent.com/u/14912729?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Simon Knott</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=Skn0tt\" title=\"Code\">💻</a> <a href=\"#ideas-Skn0tt\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=Skn0tt\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=Skn0tt\" title=\"Documentation\">📖</a></td>\n    <td align=\"center\"><a href=\"https://twitter.com/flybayer\"><img src=\"https://avatars3.githubusercontent.com/u/8813276?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Brandon Bayer</b></sub></a><br /><a href=\"#ideas-flybayer\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n    <td align=\"center\"><a href=\"http://jeremyliberman.com/\"><img src=\"https://avatars3.githubusercontent.com/u/2754163?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Jeremy Liberman</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=mrleebo\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=mrleebo\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/jorisre\"><img src=\"https://avatars1.githubusercontent.com/u/7545547?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Joris</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=jorisre\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/tomhooijenga\"><img src=\"https://avatars0.githubusercontent.com/u/1853235?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>tomhooijenga</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=tomhooijenga\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://twitter.com/ftonato\"><img src=\"https://avatars2.githubusercontent.com/u/5417662?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Ademílson F. Tonato</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=ftonato\" title=\"Tests\">⚠️</a></td>\n  </tr>\n  <tr>\n    <td align=\"center\"><a href=\"https://haspar.us\"><img src=\"https://avatars0.githubusercontent.com/u/15332326?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Piotr Monwid-Olechnowicz</b></sub></a><br /><a href=\"#ideas-hasparus\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n    <td align=\"center\"><a href=\"http://kattcorp.com\"><img src=\"https://avatars1.githubusercontent.com/u/459267?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Alex Johansson</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=KATT\" title=\"Code\">💻</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=KATT\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"https://github.com/simonedelmann\"><img src=\"https://avatars.githubusercontent.com/u/2821076?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Simon Edelmann</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/issues?q=author%3Asimonedelmann\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/blitz-js/superjson/commits?author=simonedelmann\" title=\"Code\">💻</a> <a href=\"#ideas-simonedelmann\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n    <td align=\"center\"><a href=\"https://www.samgarson.com\"><img src=\"https://avatars.githubusercontent.com/u/6242344?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Sam Garson</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/issues?q=author%3Asamtgarson\" title=\"Bug reports\">🐛</a></td>\n    <td align=\"center\"><a href=\"http://twitter.com/_markeh\"><img src=\"https://avatars.githubusercontent.com/u/1357323?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Mark Hughes</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/issues?q=author%3Amarkhughes\" title=\"Bug reports\">🐛</a></td>\n    <td align=\"center\"><a href=\"https://blog.lxxyx.cn/\"><img src=\"https://avatars.githubusercontent.com/u/13161470?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Lxxyx</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=Lxxyx\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"http://maximomussini.com\"><img src=\"https://avatars.githubusercontent.com/u/1158253?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Máximo Mussini</b></sub></a><br /><a href=\"https://github.com/blitz-js/superjson/commits?author=ElMassimo\" title=\"Code\">💻</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Prior art\n\nOther libraries that aim to solve a similar problem:\n\n- [Serialize JavaScript](https://github.com/yahoo/serialize-javascript) by Eric Ferraiuolo\n- [devalue](https://github.com/Rich-Harris/devalue) by Rich Harris\n","description":"- 🍱 Reliable serialization and deserialization - 🔐 Type safety with autocompletion - 🐾 Negligible runtime footprint - 💫 Framework agnostic - 🛠 Perfect fix for Next.js's serialisation limitations in `getServerSideProps` and `getInitialProps`","licenseText":"MIT License\n\nCopyright (c) 2020 Simon Knott and superjson contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"superjson@1.7.3-dont-mutate-serialize","dist":{"shasum":"475be6b5fc64a680c1510e8e6c42e52d848aaea8","integrity":"sha512-bGWnn/nNOs4Fvvl7u4eRC/BrCoJoisjRwHDl6utI282Y/WWD+LpYPzRRc1EpqVEujPj2J0Mob/TCd2YkFfu+XA==","tarball":"http://registry-npm.ywwl.com/superjson/download/superjson-1.7.3-dont-mutate-serialize.tgz","fileCount":111,"unpackedSize":195281,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdJ+nCRA9TVsSAnZWagAAee0P/ROu8yNt9w4sJgpsavZ5\nu4oHvGBFSJYOyJs740TAcnvE5hwAVc9/aaEMLx9nA7VgR0dB2GZoSwEIBH4T\nDdCRhcBEQk+be4Jtp9/VfZln7ef/LtFa9SauJ+mTKhWy/8ri7NmmDk4MCjSS\nQ7A7MI6ixpQX8jI+Zf4rTeIBCEDTPU8hxLoN0ykmo5+GLekpDJLHke58ucay\nQ8oj63cC6JvGlfhYLU+6gDMZDx7Cfhlv2hxvACAiKqW3PH91lXI4XfE9QSIu\nYzQmXzRIwQi3NyADopBt990CkODJ3FTbVN9Fe+lewhnufpi+Fw6O1QTTxJn3\ndSREIpDcY1MXcq9S6THapAU8MehTjEpX9NsPfgumMxNIBfhMfhMLLJ/PbsqI\nXG5kZijzL2D72iWalnM7LD4FcYZFLT52ttToN5mWVOB6MxAUOV/riDWz2WFS\nfpkJ1F56jwl3Y1c2dXmG33fXkT7oF60aBmDVEC1Psn0T397gqtdgto+AVVJE\nK00rw7s+K+hT8DgtyO/D+ffnRv964XPC+Qu30tmyKLGHZxIAV5Sv01oUWI2w\n+f88KdK99RGXQcej+g2TQcZP2SHUr/mnefF0y5d54zgBXxAtOQBP8KdWgfed\noWwcBps8g/uxYLLaF+2kcpxQlc9W9ycvFrPE/M71/rR9S71uBO42//JoB0nE\nh2J0\r\n=nC/w\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDJA8En1t97uqeJisKBl47nfGTVweKaqUUEByLVM00qSAiBS2xZ29FvkBH+IkLepa/F4FQakyHEbR5gHAm/dbgRqcw=="}],"size":49195,"noattachment":false,"key":"/superjson/-/superjson-1.7.3-dont-mutate-serialize.tgz"},"_npmUser":{"name":"skn0tt","email":"simoknott@gmail.com"},"directories":{},"maintainers":[{"name":"mattmueller","email":"mattmuelle@gmail.com"},{"name":"flybayer","email":"b@bayer.ws"},{"name":"merelinguist","email":"dylan@brookes.net"},{"name":"skn0tt","email":"simoknott@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/superjson_1.7.3-dont-mutate-serialize_1618255782762_0.15547349517563114"},"_hasShrinkwrap":false,"publish_time":1618255782897,"_cnpm_publish_time":1618255782897,"dist-tags":{"danger":"1.9.0-0","latest":"2.2.6"}}