{"_id":"serializerr","_rev":"78610","name":"serializerr","description":"Convert Errors & Objects into an easily-serialized vanilla Object.","dist-tags":{"latest":"1.0.3"},"maintainers":[{"name":"timoxley","email":""}],"time":{"modified":"2021-06-03T10:25:12.000Z","created":"2015-03-06T04:30:42.433Z","1.0.3":"2016-08-09T17:00:25.211Z","1.0.2":"2015-10-16T10:24:40.462Z","1.0.1":"2015-03-06T05:19:58.052Z","1.0.0":"2015-03-06T04:30:42.433Z"},"users":{"drdanryan":true,"johnloy":true},"author":{"name":"Tim Oxley","email":"secoif@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/timoxley/serializerr.git"},"versions":{"1.0.3":{"name":"serializerr","version":"1.0.3","description":"Convert Errors & Objects into an easily-serialized vanilla Object.","main":"serializerr.js","scripts":{"test":"(babel test.js > serializerr-test.js) && tape serializerr-test.js && standard","prepublish":"babel index.js > serializerr.js","pretest":"npm run prepublish","posttest":"rm serializerr-test.js"},"keywords":["object","error","utility","JSON","serialise","errors","non-enumerable","enumberable","stringify","properties"],"babel":{"presets":["es2015"]},"author":{"name":"Tim Oxley","email":"secoif@gmail.com"},"license":"ISC","devDependencies":{"babel-cli":"^6.11.4","babel-preset-es2015":"^6.13.2","standard":"^7.1.2","tape":"^4.6.0"},"standard":{"ignore":["serializerr.js","serializerr-test.js"]},"repository":{"type":"git","url":"git+https://github.com/timoxley/serializerr.git"},"bugs":{"url":"https://github.com/timoxley/serializerr/issues"},"homepage":"https://github.com/timoxley/serializerr","dependencies":{"protochain":"^1.0.5"},"gitHead":"fd121c29fb0c4c60f88f8b723e4928f339d842d1","_id":"serializerr@1.0.3","_shasum":"12d4c5aa1c3ffb8f6d1dc5f395aa9455569c3f91","_from":".","_npmVersion":"3.10.5","_nodeVersion":"6.3.1","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"12d4c5aa1c3ffb8f6d1dc5f395aa9455569c3f91","size":3713,"noattachment":false,"key":"/serializerr/-/serializerr-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/serializerr/download/serializerr-1.0.3.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/serializerr-1.0.3.tgz_1470762023362_0.9636031531263143"},"directories":{},"publish_time":1470762025211,"_cnpm_publish_time":1470762025211,"_hasShrinkwrap":false},"1.0.2":{"name":"serializerr","version":"1.0.2","description":"Convert Errors & Objects into an easily-serialized vanilla Object.","main":"serializerr.js","scripts":{"test":"(babel test.js > serializerr-test.js) && tape serializerr-test.js","prepublish":"babel index.js > serializerr.js","pretest":"npm run prepublish","posttest":"rm serializerr-test.js"},"keywords":["object","error","utility","JSON","serialise","errors","non-enumerable","enumberable","stringify","properties"],"author":{"name":"Tim Oxley","email":"secoif@gmail.com"},"license":"ISC","devDependencies":{"babel":"^5.8.23","tape":"^4.2.1"},"repository":{"type":"git","url":"git+https://github.com/timoxley/serializerr.git"},"bugs":{"url":"https://github.com/timoxley/serializerr/issues"},"homepage":"https://github.com/timoxley/serializerr","dependencies":{"protochain":"^1.0.3"},"gitHead":"63fe2a3968153ace55109b67cdbea96d92a9c4b1","_id":"serializerr@1.0.2","_shasum":"ac8b3d8cada8fc6164df20568fc6182952731b9a","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.2","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"ac8b3d8cada8fc6164df20568fc6182952731b9a","size":3544,"noattachment":false,"key":"/serializerr/-/serializerr-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/serializerr/download/serializerr-1.0.2.tgz"},"directories":{},"publish_time":1444991080462,"_cnpm_publish_time":1444991080462,"_hasShrinkwrap":false},"1.0.1":{"name":"serializerr","version":"1.0.1","description":"Convert Errors & Objects into an easily-serialized vanilla Object.","main":"serializerr.js","scripts":{"test":"(babel test.js > serializerr-test.js) && tape serializerr-test.js","prepublish":"babel index.js > serializerr.js","pretest":"npm run prepublish","posttest":"rm serializerr-test.js"},"keywords":["object","error","utility","JSON","serialise","errors","non-enumerable","enumberable","stringify","properties"],"author":{"name":"Tim Oxley","email":"secoif@gmail.com"},"license":"ISC","devDependencies":{"babel":"^4.6.6","tape":"^3.5.0"},"repository":{"type":"git","url":"https://github.com/timoxley/serializerr.git"},"bugs":{"url":"https://github.com/timoxley/serializerr/issues"},"homepage":"https://github.com/timoxley/serializerr","dependencies":{"protochain":"^1.0.1"},"gitHead":"fcf1baaf47c60d351910f81565923f3458684a95","_id":"serializerr@1.0.1","_shasum":"7351615fc06a6f1756a6070bb4e8d27c4149a53f","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.10.36","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"7351615fc06a6f1756a6070bb4e8d27c4149a53f","size":3454,"noattachment":false,"key":"/serializerr/-/serializerr-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/serializerr/download/serializerr-1.0.1.tgz"},"directories":{},"publish_time":1425619198052,"_cnpm_publish_time":1425619198052,"_hasShrinkwrap":false},"1.0.0":{"name":"serializerr","version":"1.0.0","description":"Convert Errors & Objects into an easily-serialized vanilla Object.","main":"serializerr.js","scripts":{"test":"(babel test.js > serializerr-test.js) && tape serializerr-test.js","prepublish":"babel index.js > serializerr.js","pretest":"npm run prepublish","posttest":"rm serializerr-test.js"},"keywords":["object","error","utility","JSON","serialise","errors","non-enumerable","enumberable","stringify","properties"],"author":{"name":"Tim Oxley","email":"secoif@gmail.com"},"license":"ISC","devDependencies":{"babel":"^4.6.6","tape":"^3.5.0"},"repository":{"type":"git","url":"https://github.com/timoxley/serializerr.git"},"bugs":{"url":"https://github.com/timoxley/serializerr/issues"},"homepage":"https://github.com/timoxley/serializerr","dependencies":{"protochain":"^1.0.1"},"gitHead":"bcdadec044e606fd8d55ccd3b6597469082ea512","_id":"serializerr@1.0.0","_shasum":"4b0a99b1763b3d80630cc45a540c3ebc5ff14933","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.10.36","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"4b0a99b1763b3d80630cc45a540c3ebc5ff14933","size":2966,"noattachment":false,"key":"/serializerr/-/serializerr-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/serializerr/download/serializerr-1.0.0.tgz"},"directories":{},"publish_time":1425616242433,"_cnpm_publish_time":1425616242433,"_hasShrinkwrap":false}},"readme":"# serializerr\n\nConvert Errors & Objects into an easily-serialized vanilla Object.\n\n[![Build Status](https://travis-ci.org/timoxley/serializerr.png?branch=master)](https://travis-ci.org/timoxley/serializerr)\n\n`serializerr` creates a vanilla `Object` with a flattened prototype\nchain & any non-enumerable properties mapped to enumerable properties.\n\nThis allows `Error` objects to be serialised to JSON without losing\nimportant data.\n\n## Installation\n\n```\nnpm install serializerr\n```\n\n## Usage\n\n```js\n\nvar wellSerializedError = JSON.parse(JSON.stringify(\n  serializerr(error)\n))\n\nconsole.log(wellSerializedError.name) // Error\nconsole.log(wellSerializedError.message) // an error occurred\nconsole.log(wellSerializedError.stack) // Error: an error occurred\\n  at Test.<anonymous> ...\n\n```\n\n## Example\n\n```js\n\nvar serializerr = require('serializerr')\n\nvar error = new Error('an error')\n\n// simulate transferring an Error object over the wire as JSON\n// without first passing through serializerr\nvar poorlySerializedError = JSON.parse(JSON.stringify(error))\n\n// oh dear:\nconsole.log(poorlySerializedError.name) // undefined\nconsole.log(poorlySerializedError.message) // undefined\nconsole.log(poorlySerializedError.stack) // undefined\n\n// bring forth the serializerr\nvar errorObject = serializerr(error)\n\nvar wellSerializedError = JSON.parse(JSON.stringify(errorObject))\n\n// properties are conserved!\nconsole.log(wellSerializedError.name) // Error\nconsole.log(wellSerializedError.message) // an error occurred\nconsole.log(wellSerializedError.stack) // Error: an error occurred\\n  at Test.<anonymous> ...\n\n// note errorObject is a vanilla Object, not an Error\nerrorObject instanceof Error // false\n```\n\n## Why\n\nIf you've ever tried to send an Error over a JSON-encoded connection\nyou've probably been surprised to find all the useful information is\nsapped out of it; all the juicy properties like `name`, `message` &\n`stack` are non-enumerable thus they are not included in the\nstringified JSON. This may be non-standard behaviour, as I could not\nlocate any mention in either the ES5.1 or the ES6 spec about it, but\nError properties are non-enumerable both in V8 (Chrome/io.js/Node.js) &\nSpiderMonkey (Firefox).\n\nI believe Error property non-enumerability was added as a security\nmeasure to prevent stack traces and other sensitive information\naccidentally leaking, but it's not uncommon to actually want to send\nthe data in Error objects over the wire.\n\n`serializerr` makes an Object suitable for serializing to & from\nJSON. Not restricted to use with Errors, will work with any Object.\n\n## Notes on 'ize' vs 'ise'\n\nName was selected as programming world is mostly Americanised, and npm\nsearch does not seem to do effective stemming.\n\nThis decision came with strong feelings of guilt and shame about what I thought\nwas blasphemous Americanised spelling, but it turns out this is a\nmisconception thus I am pardoned:\n\n> The -ize spelling is often incorrectly seen as an Americanism in\n> Britain. However, the Oxford English Dictionary (OED) recommends -ize\n> and notes that the -ise spelling is from French.\n\nFrom [Wikipedia: American and British English spelling differences](http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences#-ise.2C_-ize_.28-isation.2C_-ization.29)\n\n## License\n\nISC\n","_attachments":{},"homepage":"https://github.com/timoxley/serializerr","bugs":{"url":"https://github.com/timoxley/serializerr/issues"},"license":"ISC"}