{"name":"json-stringify-deterministic","description":"deterministic version of JSON.stringify() so you can get a consistent hash from stringified results.","homepage":"https://github.com/Kikobeats/json-stringify-deterministic","version":"1.0.6","main":"lib","author":{"name":"Kiko Beats","email":"josefrancisco.verdu@gmail.com","url":"https://github.com/Kikobeats"},"contributors":[{"name":"Perlover","email":"perlover@perlover.com"},{"name":"Vladyslav Mashkin","email":"jsdream@users.noreply.github.com"}],"repository":{"type":"git","url":"git+https://github.com/kikobeats/json-stringify-deterministic.git"},"bugs":{"url":"https://github.com/Kikobeats/json-stringify-deterministic/issues"},"keywords":["deterministic","hash","json","sort","stable","stringify"],"devDependencies":{"@commitlint/cli":"latest","@commitlint/config-conventional":"latest","c8":"latest","ci-publish":"latest","conventional-github-releaser":"latest","finepack":"latest","git-authors-cli":"latest","mocha":"latest","nano-staged":"latest","npm-check-updates":"latest","prettier-standard":"latest","should":"latest","simple-git-hooks":"latest","standard":"latest","standard-markdown":"latest","standard-version":"latest"},"engines":{"node":">= 4"},"scripts":{"clean":"rm -rf node_modules","contributors":"(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true","coveralls":"nyc report --reporter=text-lcov | coveralls","lint":"standard && standard-markdown","postrelease":"npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)","prerelease":"npm run update:check && npm run contributors","pretest":"npm run lint","release":"standard-version -a","release:github":"conventional-github-releaser -p angular","release:tags":"git push --follow-tags origin HEAD:master","test":"c8 mocha --require should","update":"ncu -u","update:check":"ncu -- --error-level 2"},"license":"MIT","commitlint":{"extends":["@commitlint/config-conventional"]},"nano-staged":{"*.js":["prettier-standard"],"*.md":["standard-markdown"],"package.json":["finepack"]},"simple-git-hooks":{"commit-msg":"npx commitlint --edit","pre-commit":"npx nano-staged"},"standard":{"globals":["describe","it"]},"gitHead":"804892529368de4e4b289fac1db177fcf8a55c72","_id":"json-stringify-deterministic@1.0.6","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-/LbStPoVnzj/FBFxxdJH0bXesMIVTwZzO3K/5Jr74/exrBOV2/Hw96dJMryhfwnE6Jp5tnByh+RvRl+omSzLVg==","shasum":"997a82e5ef23697b91476b32b0f8e16d17ccfd5c","tarball":"http://registry-npm.ywwl.com/json-stringify-deterministic/download/json-stringify-deterministic-1.0.6.tgz","fileCount":6,"unpackedSize":10470,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCse92slhiAWf3TZhxbHkDPpfybRkBO8FTPwJqbWdUyxgIgJ0jIh4eeuu1KCL67WsjQE3dVmwlRVBf03y81bYj91pE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiVGKjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqaiA/+O+k3X3rL8ywhXC/GYuCBar5glayG6KB9ZIarjRfIdIVgeFjc\r\nySD1EDmLuxV/IiPQ3Kzf/he5o+tYjhXFxMjRJvgxJ//pJh2XtewUqOV+HWZb\r\n5eyckW/ewSJWUXp1b6YnDW7D5q4RTF6Jf6Gcs0SlYhZa2UVeoTR7QC3+QQSJ\r\n1WzAUt2dixl6hXE3P8no1gPbQ7uZ0IOjneuz5XI/agGJJIsDUlONa2KlGpIX\r\ntJSiohMNL4eO7PdvVS83msDbxTOKqXVQ2GDc5/Sz2xKC0OzPZkiCQV2Gkmlq\r\ndepMk+Ze8+mkzUw6XnX6j85qNxpo7oWEwu5NmmemTz5/UV4DQjVsXgftTohy\r\nsOODN/01D765amCqxa4u+lcbolvjPzdLvpMJ/7+JQEmwEo0XIZLefj76nIoH\r\nJzBsYHkJbhRpg4KB56+kUFZB3JEgdpQCYL9x26sTtdpvWk3gjwAoli5VDYHL\r\n+ro6Bf2ykSWkyp5fVN/eqZklif+fJiQHmx/D9W0/+DvDv0+0Clv33XWCVO15\r\nw0vAoqTzrjV8Uh0pQ3aNJqmFmmoCU0ogMBkMRJsIzyxCrb4/RHr6PFQx8XQc\r\n0+lmKOIo0Hnztx9/rjKOmawiKGzN7qX0UYkPlc8+vCwnFDpcP9KqavHUNwFq\r\nryzTDnhgQKi1jT8vl7dmJhuGbpr6zx48S1I=\r\n=k6GI\r\n-----END PGP SIGNATURE-----\r\n","size":4187,"noattachment":false,"key":"/json-stringify-deterministic/-/json-stringify-deterministic-1.0.6.tgz"},"_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"directories":{},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-deterministic_1.0.6_1649697443047_0.08016766784559826"},"_hasShrinkwrap":false,"readme":"# json-stringify-deterministic\n\n![Last version](https://img.shields.io/github/tag/Kikobeats/json-stringify-deterministic.svg?style=flat-square)\n[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/json-stringify-deterministic.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/json-stringify-deterministic)\n[![NPM Status](https://img.shields.io/npm/dm/json-stringify-deterministic.svg?style=flat-square)](https://www.npmjs.org/package/json-stringify-deterministic)\n\n> Deterministic version of `JSON.stringify()`, so you can get a consistent hash from stringified results.\n\nSimilar to [json-stable-stringify](https://github.com/substack/json-stable-stringify) *but*:\n\n- No Dependencies. Minimal as possible.\n- Better cycles detection.\n- Support serialization for object without `.toJSON` (such as `RegExp`).\n- Provides built-in TypeScript declarations.\n\n## Install\n\n```bash\nnpm install json-stringify-deterministic --save\n```\n\n## Usage\n\n```js\nconst stringify = require('json-stringify-deterministic')\nconst obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 }\n\nconsole.log(stringify(obj))\n// => {\"a\":3,\"b\":[{\"x\":4,\"y\":5,\"z\":6},7],\"c\":8}\n```\n\n## API\n\n### stringify(&lt;obj&gt;, [opts])\n\n#### obj\n\n*Required*<br>\nType: `object`\n\nThe input `object` to be serialized.\n\n#### opts\n\n##### opts.stringify\n\nType: `function`\nDefault: `JSON.stringify`\n\nDeterminate how to stringify primitives values.\n\n##### opts.cycles\n\nType: `boolean`\nDefault: `false`\n\nDeterminate how to resolve cycles.\n\nUnder `true`, when a cycle is detected, `[Circular]` will be inserted in the node.\n\n##### opts.compare\n\nType: `function`\n\nCustom comparison function for object keys.\n\nYour function `opts.compare` is called with these parameters:\n\n``` js\nopts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue })\n```\n\nFor example, to sort on the object key names in reverse order you could write:\n\n``` js\nconst stringify = require('json-stringify-deterministic')\n\nconst obj = { c: 8, b: [{z: 6,y: 5,x: 4}, 7], a: 3 }\nconst objSerializer = stringify(obj, function (a, b) {\n  return a.key < b.key ? 1 : -1\n})\n\nconsole.log(objSerializer)\n// => {\"c\":8,\"b\":[{\"z\":6,\"y\":5,\"x\":4},7],\"a\":3}\n```\n\nOr if you wanted to sort on the object values in reverse order, you could write:\n\n```js\nconst stringify = require('json-stringify-deterministic')\n\nconst obj = { d: 6, c: 5, b: [{ z: 3, y: 2, x: 1 }, 9], a: 10 }\nconst objtSerializer = stringify(obj, function (a, b) {\n  return a.value < b.value ? 1 : -1\n})\n\nconsole.log(objtSerializer)\n// => {\"d\":6,\"c\":5,\"b\":[{\"z\":3,\"y\":2,\"x\":1},9],\"a\":10}\n```\n\n##### opts.space\n\nType: `string`<br>\nDefault: `''`\n\nIf you specify `opts.space`, it will indent the output for pretty-printing.\n\nValid values are strings (e.g. `{space: \\t}`). For example:\n\n```js\nconst stringify = require('json-stringify-deterministic')\n\nconst obj = { b: 1, a: { foo: 'bar', and: [1, 2, 3] } }\nconst objSerializer = stringify(obj, { space: '  ' })\nconsole.log(objSerializer)\n// => {\n//   \"a\": {\n//     \"and\": [\n//       1,\n//       2,\n//       3\n//     ],\n//     \"foo\": \"bar\"\n//   },\n//   \"b\": 1\n// }\n```\n\n##### opts.replacer\n\nType: `function`<br>\n\nThe replacer parameter is a function `opts.replacer(key, value)` that behaves\nthe same as the replacer\n[from the core JSON object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_native_JSON#The_replacer_parameter).\n\n## Related\n\n- [sort-keys-recursive](https://github.com/Kikobeats/sort-keys-recursive): Sort the keys of an array/object recursively.\n\n## License\n\nMIT © [Kiko Beats](https://github.com/Kikobeats).\n","publish_time":1649697443184,"_cnpm_publish_time":1649697443184,"dist-tags":{"latest":"1.0.18"}}