{"_id":"@lachenmayer/buffer-json","_rev":"3-36b0490ed3a341ae8f9b308887edf2db","name":"@lachenmayer/buffer-json","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@lachenmayer/buffer-json","version":"1.0.0","description":"JSON.stringify & JSON.parse which can encode/decode buffers.","main":"index.js","scripts":{"test":"standard --fix && node test.js"},"repository":{"type":"git","url":"git+https://github.com/lachenmayer/buffer-json.git"},"keywords":["JSON","parse","stringify","buffer","reviver","replacer","base64"],"author":{"name":"harry lachenmayer","email":"harrylachenmayer@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lachenmayer/buffer-json/issues"},"homepage":"https://github.com/lachenmayer/buffer-json#readme","devDependencies":{"standard":"^12.0.1","tape":"^4.10.0"},"gitHead":"b0559d5215af4d84bdddd88e1e848b7a2ee1fbd4","_id":"@lachenmayer/buffer-json@1.0.0","_npmVersion":"6.5.0","_nodeVersion":"11.6.0","_npmUser":{"name":"lachenmayer","email":"harrylachenmayer@gmail.com"},"dist":{"integrity":"sha512-N1PkKDhkBOlZyoHXTuMNo3XNwa1cTL5lSaKMNcOyYQejFtwxljd9NWiUEIXudHPFicFmqO+CKUuCnNhlDBGerg==","shasum":"a5d56089cc4122d14ffc145c42d28476b54c3b52","tarball":"https://registry.npmjs.org/@lachenmayer/buffer-json/-/buffer-json-1.0.0.tgz","fileCount":4,"unpackedSize":6436,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcZX2QCRA9TVsSAnZWagAAXa0QAJvFlkuch0mOCwyqy4N4\nvzgqYenT+4JCtcHybcaSt74BNnnBzmsgqIfNMjbjSCgvleNVo6PcjvEaAp7J\nDFw0ngca281XDLmLZkI8D9HBpG4/VudaJq0p7olow7vy8H2D2KIp2ApjqfEM\n69UroHaIOabwZBpSwyZfPrxNPKPT+rjQf1DnBcivnEHh4CSjsupWPKyQeq3Z\nqy2gy9ee2vtn87omXjxvCKJAuLTPwlAxlqjHRXj9vjhjiGviBoHt7oR72957\nc7qhXasLVzoFBgDGJf2xip1fGNDTn+PGxAaoqZiDBQ8RLhot9BDwOFo9i4v+\n5DNFva68Icd2pS9vZlWe5Px0hj7ew+SmYyOjmxd3BQXRd/VSh4XojvuTKGIl\ntG/cA/h+jKvRhfxeMZzerY5Am+fEtOWCrj+9E452SA9XVNNHPId3ObZ3qvSO\nvQen6+d9VHBzsyXpfFt4quYdiPcUrD+4NX/UbdMO25oQRlQFYKwyxm1l50hj\nsJffBNGIv+WgcvAMIWcpuuip2W0odWCgwXYMFo9VRvLwfkYdKGOJ1i1nh9bi\nhEyYl3mPEEO+cdG5kSvAksVbaEIiyr+T5D0wc3R3NcMg7NkdRfEDWFdqsjky\nqZ5SzMwffvWNEeTRz1oQneMlmYxWaLMybPdMy+dPEk3z711VsKNSyluR/EEM\nsCgR\r\n=krYz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCS8IHwO0VLf1I8wRnJXH1exgPTFc5gH7+et89xe6hG4AIgB1Fg5gyt7si/CbDAN3S5AHvZ7uM5PkpQEERa+T+VE+o="}]},"maintainers":[{"name":"lachenmayer","email":"harrylachenmayer@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/buffer-json_1.0.0_1550155151499_0.20966892613624055"},"_hasShrinkwrap":false},"1.0.1":{"name":"@lachenmayer/buffer-json","version":"1.0.1","description":"JSON.stringify & JSON.parse which can encode/decode buffers.","main":"index.js","scripts":{"test":"standard --fix && node test.js"},"repository":{"type":"git","url":"git+https://github.com/lachenmayer/buffer-json.git"},"keywords":["JSON","parse","stringify","buffer","reviver","replacer","base64"],"author":{"name":"harry lachenmayer","email":"harrylachenmayer@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lachenmayer/buffer-json/issues"},"homepage":"https://github.com/lachenmayer/buffer-json#readme","devDependencies":{"standard":"^12.0.1","tape":"^4.10.0"},"gitHead":"706ffe7d527fde058de9de4f06b3d2e174561d0d","_id":"@lachenmayer/buffer-json@1.0.1","_npmVersion":"6.5.0","_nodeVersion":"11.6.0","_npmUser":{"name":"lachenmayer","email":"harrylachenmayer@gmail.com"},"dist":{"integrity":"sha512-sz7rN2DOjX7Db7NISpyCP52s6/QJwvcLvvzZtra035oFFjZogOmruejza6SbVTI88LI9DetC9oYD1h/ScrLQ7Q==","shasum":"d6b057cbfb4c4dbbb50b5db3d6fbd5273fe4746c","tarball":"https://registry.npmjs.org/@lachenmayer/buffer-json/-/buffer-json-1.0.1.tgz","fileCount":4,"unpackedSize":6906,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcZYI7CRA9TVsSAnZWagAAqYEP/A3MpfQhlNfxc6fWRh3O\nG6zzH7h2b1rgTO1yNOtwXO0aIKtqdE5KS7ZmyoI+EKUNt4L9rGF+gZj7xvA1\nyyE+urJijv5aFukuL3TI4kVsE4G2C+oJWBUyBXVRlDOQz9Nxit6g7l6JxqgX\nC0G4sNbdcH6+hyyBKjh3Ck+Bzgw56zSg1Tb7NyGsm7QwbOv47unaZVRe5rMe\nVr5a7ZFDRuJP4t+bT8pF4GhmBizUFGmq75V/V7HNkbN41tKibj/N3JSbUEoN\neeRLH/ErZumjdlhBDCy/k4SV9Iz5ILRShqnh+Lt0Z3ceOo9iguh/PYMqklwt\nosjWNjVA4mqdL5TRxRkMeMyaN6FKp8k57fjmwnEanjM3VX3/tzpBlE9ikU5y\n1deXn+/ajLIUi50TZQ1uvX0n9CRoN/e34PVZKTEC/EOXBbQjOAiXKYwhBHuG\nHcxhy7CYQGtAe88+qvV7W2knBMxq8SsXSE0vILJf/rVfyb36gP4S7gFWWd+k\nw9eBVBClwL5sAuECoPajxowrl/D10ryiK4NawD0BZmVyha3hurazB6cQ3QlR\nfIi4wAW8KXdYSL1m8mHSZNe1kyPnZpMu+nYq8qfK4GYJ1B6xjaPHgl7e0C/r\nPGVMDhmAEkKuomIqNFwB6eQKzxQ5+8623gzSf9MYedalpSBNFhRLtSvLS9Wo\ni5TH\r\n=4HV9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvqRVbnSptFpLId0ntB7Kr8iRD+6VaGZzNSnmVEWSY/AIgYlyQWYWZ4Zs6/+eJFGDVd1EMsJfxJogCO7edqBCtjiQ="}]},"maintainers":[{"name":"lachenmayer","email":"harrylachenmayer@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/buffer-json_1.0.1_1550156346852_0.3398251187311594"},"_hasShrinkwrap":false,"deprecated":"the changes in this package have been upstreamed to buffer-json. use buffer-json instead."}},"time":{"created":"2019-02-14T14:39:11.308Z","1.0.0":"2019-02-14T14:39:11.668Z","modified":"2022-04-06T00:38:49.473Z","1.0.1":"2019-02-14T14:59:06.940Z"},"maintainers":[{"name":"lachenmayer","email":"harrylachenmayer@gmail.com"}],"description":"JSON.stringify & JSON.parse which can encode/decode buffers.","homepage":"https://github.com/lachenmayer/buffer-json#readme","keywords":["JSON","parse","stringify","buffer","reviver","replacer","base64"],"repository":{"type":"git","url":"git+https://github.com/lachenmayer/buffer-json.git"},"author":{"name":"harry lachenmayer","email":"harrylachenmayer@gmail.com"},"bugs":{"url":"https://github.com/lachenmayer/buffer-json/issues"},"license":"MIT","readme":"# buffer-json\n\n```\nnpm install @lachenmayer/buffer-json\n```\n\n```js\nconst BJSON = require('@lachenmayer/buffer-json')\n\nconst str = BJSON.stringify({ buf: Buffer.from('hello') })\n// => '{\"buf\":{\"type\":\"Buffer\",\"data\":\"base64:aGVsbG8=\"}}'\n\nBJSON.parse(str)\n// => { buf: <Buffer 68 65 6c 6c 6f> }\n```\n\nThe [`Buffer`](https://nodejs.org/api/buffer.html#buffer_buffer) class in Node.js is used to represent binary data. JSON does not specify a way to encode binary data, so the Node.js implementation of `JSON.stringify` represents buffers as an object of shape `{ type: \"Buffer\", data: [<bytes as numbers>] }`. Unfortunately, `JSON.parse` does not turn this structure back into a `Buffer` object:\n\n```\n$ node\n> JSON.parse(JSON.stringify({ buf: Buffer.from('hello world') }))\n{ buf:\n   { type: 'Buffer',\n     data: [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ] } }\n```\n\n`JSON.stringify` and `JSON.parse` accept arguments called [`replacer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) and [`reviver`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) respectively which allow customizing the parsing/encoding behavior. This module provides a replacer which encodes Buffer data as a base64-encoded string, and a reviver which turns JSON objects which contain buffer-like data (either as arrays of numbers or strings) into `Buffer` instances. All other types of values are parsed/encoded as normal.\n\n## API\n\n### `stringify(value[, space])`\n\nConvenience wrapper for [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) with the `replacer` described below.\n\n### `parse(text)`\n\nConvenience wrapper for [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) with the `reviver` described below.\n\n### `replacer(key, value)`\n\nA [`replacer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) implementation which turns every value that is a `Buffer` instance into an object of shape `{ type: 'Buffer', data: 'base64:<base64-encoded buffer content>' }`. Empty buffers are encoded as `{ type: 'Buffer', data: '' }`.\n\n### `reviver(key, value)`\n\nA [`reviver`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) implementation which turns every object of shape `{ type: 'Buffer', data: <array of numbers or string> }` into a `Buffer` instance.\n\n## History\n\nThis is a fork of https://github.com/jprichardson/buffer-json/ - I initially forked the module because it crashed when used with objects where some values are `null` or `undefined`. Looking deeper into it I noticed that it was using the deprecated Buffer constructor and other deprecated methods from mocha. I decided to fix the bugs, simplify the logic, and bring it up to date with current APIs (ie. using `Buffer.from(...)` instead of `new Buffer` and using [tape](https://npm.im/tape) for tests).\n\n## Related modules\n\n- [`buffer-json-encoding`](https://github.com/lachenmayer/buffer-json-encoding): an [`abstract-encoding`](https://github.com/mafintosh/abstract-encoding) compatible JSON encoder/decoder which uses this module.\n\n## License\n\nMIT","readmeFilename":"README.md"}