{"name":"safe-stringify","version":"0.0.1","keywords":["node","json","stringify","cycle"],"author":{"name":"Ned Rockson","email":"nedrocks@gmail.com"},"license":"MIT","_id":"safe-stringify@0.0.1","maintainers":[{"name":"nedrocks","email":"ned@nedrockson.com"}],"homepage":"https://github.com/nedrocks/safe-stringify#readme","bugs":{"url":"https://github.com/nedrocks/safe-stringify/issues"},"dist":{"shasum":"3091f9381a886634ab461a75d31208149a45616d","tarball":"http://registry-npm.ywwl.com/safe-stringify/download/safe-stringify-0.0.1.tgz","integrity":"sha512-HlrC4wumvhUAOln+BixHSTdKIOQTz/zBXUp6eY8r+AzGTpvT4pqrsKhj/qhMzj49pqALvCzWGL4IDUizvBWefw==","signatures":[{"sig":"MEUCIA2rUIXVICrQ+DORhiQm4DmPkoFQb7W3LBDVAXi9my2tAiEAsYwG3lptsnMubhprdszwqsVOjTljQlL8CbVKcb3dQ6k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":2731,"noattachment":false,"key":"/safe-stringify/-/safe-stringify-0.0.1.tgz"},"jest":{"scriptPreprocessor":"<rootDir>/node_modules/babel-jest","testFileExtensions":["es6","js"],"moduleFileExtensions":["js","json","es6"],"unmockedModulePathPatterns":["<rootDir>/node_modules/babel-runtime"]},"main":"index.js","_from":".","_shasum":"3091f9381a886634ab461a75d31208149a45616d","gitHead":"f524a8ebfde8bc9b137b63b33568c097e887dc72","scripts":{"test":"jest"},"_npmUser":{"name":"nedrocks","email":"ned@nedrockson.com"},"repository":{"url":"git+https://github.com/nedrocks/safe-stringify.git","type":"git"},"_npmVersion":"3.9.5","description":"A safe substitute for JSON.stringify","directories":{},"_nodeVersion":"6.2.2","devDependencies":{"babel":"^6.5.2","jest-cli":"^13.2.3","babel-cli":"^6.10.1","babel-jest":"^13.2.2","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","babel-plugin-transform-flow-strip-types":"^6.8.0"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify-0.0.1.tgz_1468454507465_0.41487714159302413","host":"packages-12-west.internal.npmjs.com"},"readme":"# safe-stringify\n\n> Serialize objects to JSON with handling for circular references\n\n`JSON.stringify()` throws an error if the object contains circular references. This package replaces circular references with `\"[Circular]\"`.\n\n## Install\n\n```sh\nnpm install safe-stringify\n```\n\n## Usage\n\n```js\nimport safeStringify from 'safe-stringify';\n\nconst foo = {a: true};\nfoo.b = foo;\n\nconsole.log(safeStringify(foo));\n//=> '{\"a\":true,\"b\":\"[Circular]\"}'\n\nconsole.log(JSON.stringify(foo));\n//=> TypeError: Converting circular structure to JSON\n\n```\n\n## API\n\n### safeStringify(value, options?)\n\nReturns a string.\n\n*Note: There is no `replacer` option as I didn't need that, but “pull request welcome” if you need it.*\n\n#### value\n\nType: `unknown`\n\nThe value to convert to a JSON string.\n\n#### options\n\nType: `object`\n\n##### indentation\n\nType: `'string' | 'number'`\n\nThe indentation of the JSON.\n\nBy default, the JSON is not indented. Set it to `'\\t'` for tab indentation or the number of spaces you want.\n\n##### trace\n\nType: `boolean`\n\nInclude the full object path in circular reference markers, like `[Circular *a.b]`.\n\n```js\nimport safeStringify from 'safe-stringify';\n\nconst bar = {a: {b: {}}};\nbar.a.b.c = bar.a;\n\nconsole.log(safeStringify(bar, {trace: true}));\n//=> '{\"a\":{\"b\":{\"c\":\"[Circular *a]\"}}}'\n```\n\n## FAQ\n\n### Why another safe stringify package?\n\nThe existing ones either did too much, did it incorrectly, or used inefficient code (not using `WeakSet`). For example, many packages incorrectly replaced all duplicate objects, not just circular references, and did not handle circular arrays.\n\n## Related\n\n- [decircular](https://github.com/sindresorhus/decircular) - Remove circular references from objects\n","publish_time":1468454508080,"_cnpm_publish_time":1468454508080,"dist-tags":{"latest":"1.3.0"}}