{"_id":"json-stringify-nice","_rev":"181135","name":"json-stringify-nice","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","dist-tags":{"latest":"1.1.4"},"maintainers":[{"name":"isaacs","email":""}],"time":{"modified":"2022-10-18T09:48:56.000Z","created":"2019-11-09T19:06:00.444Z","1.1.4":"2021-05-06T22:47:49.572Z","1.1.3":"2021-04-01T18:40:00.859Z","1.1.2":"2021-03-26T18:49:13.596Z","1.1.1":"2019-11-09T19:46:03.832Z","1.1.0":"2019-11-09T19:36:16.259Z","1.0.1":"2019-11-09T19:09:09.689Z","1.0.0":"2019-11-09T19:06:00.444Z"},"users":{},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"versions":{"1.1.4":{"name":"json-stringify-nice","version":"1.1.4","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","posttest":"npm run lint","snap":"tap","postsnap":"npm run lintfix","eslint":"eslint","lint":"npm run eslint -- index.js test/**/*.js","lintfix":"npm run lint -- --fix","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"test-env":["LC_ALL=sk"],"check-coverage":true},"devDependencies":{"eslint":"^7.25.0","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0","eslint-plugin-standard":"^5.0.0","tap":"^15.0.6"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"75257e5749847bbfc416bd415cdc999c80bc8917","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.1.4","_nodeVersion":"16.0.0","_npmVersion":"7.11.2","dist":{"shasum":"2c937962b80181d3f317dd39aa323e14f5a60a67","size":2614,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.1.4.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.1.4.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.1.4_1620341269444_0.8873571396925528"},"_hasShrinkwrap":false,"publish_time":1620341269572,"_cnpm_publish_time":1620341269572,"_cnpmcore_publish_time":"2021-12-13T18:35:41.198Z"},"1.1.3":{"name":"json-stringify-nice","version":"1.1.3","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"a86fef6f5c62a5587eb77e5e173200d297e2903f","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.1.3","_nodeVersion":"15.3.0","_npmVersion":"7.7.6","dist":{"shasum":"43991531d674ad5c19152d519047849935293add","size":2465,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.1.3.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.1.3.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.1.3_1617302400730_0.10472747407444571"},"_hasShrinkwrap":false,"publish_time":1617302400859,"_cnpm_publish_time":1617302400859,"_cnpmcore_publish_time":"2021-12-13T18:35:41.445Z"},"1.1.2":{"name":"json-stringify-nice","version":"1.1.2","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"5a6f13c30a343631c213ce04cc1495578f5ce7de","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.1.2","_nodeVersion":"15.3.0","_npmVersion":"7.7.4","dist":{"shasum":"955040f00eac984ad81b6d2966a07b5a6e19e512","size":3766,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.1.2.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.1.2.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.1.2_1616784553477_0.5779606316368797"},"_hasShrinkwrap":false,"publish_time":1616784553596,"_cnpm_publish_time":1616784553596,"_cnpmcore_publish_time":"2021-12-13T18:35:41.749Z"},"1.1.1":{"name":"json-stringify-nice","version":"1.1.1","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"2cd2d3da0a5f033cd641c2097e6fe42b494ddbe2","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.1.1","_nodeVersion":"12.12.0","_npmVersion":"6.13.0","dist":{"shasum":"1377579345c9ac3b0d940c1928af348ff7b42f8b","size":31711,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.1.1.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.1.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.1.1_1573328763666_0.2902019492307619"},"_hasShrinkwrap":false,"publish_time":1573328763832,"_cnpm_publish_time":1573328763832},"1.1.0":{"name":"json-stringify-nice","version":"1.1.0","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"e93e266abc3e172d0e3763910278b1b8ef361ad6","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.1.0","_nodeVersion":"12.12.0","_npmVersion":"6.13.0","dist":{"shasum":"7b5d7c19b4937718206623a4f41dc76442960409","size":31692,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.1.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.1.0_1573328176132_0.27706128925476126"},"_hasShrinkwrap":false,"publish_time":1573328176259,"_cnpm_publish_time":1573328176259},"1.0.1":{"name":"json-stringify-nice","version":"1.0.1","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/isaacs/json-stringify-nice.git"},"gitHead":"0371b485827216f76cf8cecbf829fdf4951f462a","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","_id":"json-stringify-nice@1.0.1","_nodeVersion":"12.12.0","_npmVersion":"6.13.0","dist":{"shasum":"e7cc0b732aa7eff8ce6dc4bdf64a6407a657874e","size":31250,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.0.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.0.1_1573326549544_0.4597759407756081"},"_hasShrinkwrap":false,"publish_time":1573326549689,"_cnpm_publish_time":1573326549689},"1.0.0":{"name":"json-stringify-nice","version":"1.0.0","description":"Stringify an object sorting scalars before objects, and defaulting to 2-space indent","author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://izs.me"},"license":"ISC","scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true},"devDependencies":{"tap":"^14.9.2"},"funding":{"url":"https://github.com/sponsors/isaacs"},"gitHead":"548b82e81267d44e2b043da519d1cb981c4fb91a","_id":"json-stringify-nice@1.0.0","_nodeVersion":"12.12.0","_npmVersion":"6.13.0","dist":{"shasum":"e9c547aabf174cf98c0ac470df6e331d579f85b1","size":31141,"noattachment":false,"key":"/json-stringify-nice/-/json-stringify-nice-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/json-stringify-nice/download/json-stringify-nice-1.0.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-nice_1.0.0_1573326360256_0.9502846326514947"},"_hasShrinkwrap":false,"publish_time":1573326360444,"_cnpm_publish_time":1573326360444}},"readme":"# json-stringify-nice\n\nStringify an object sorting scalars before objects, and defaulting to\n2-space indent.\n\nSometimes you want to stringify an object in a consistent way, and for\nhuman legibility reasons, you may want to put any non-object properties\nahead of any object properties, so that it's easier to track the nesting\nlevel as you read through the object, but you don't want to have to be\nmeticulous about maintaining object property order as you're building up\nthe object, since it doesn't matter in code, it only matters in the output\nfile.  Also, it'd be nice to have it default to reasonable spacing without\nhaving to remember to add `, null, 2)` to all your `JSON.stringify()`\ncalls.\n\nIf that is what you want, then this module is for you, because it does\nall of that.\n\n## USAGE\n\n```js\nconst stringify = require('json-stringify-nice')\nconst obj = {\n  z: 1,\n  y: 'z',\n  obj: { a: {}, b: 'x' },\n  a: { b: 1, a: { nested: true} },\n  yy: 'a',\n}\n\nconsole.log(stringify(obj))\n/* output:\n{\n  \"y\": \"z\", <-- alphabetical sorting like whoa!\n  \"yy\": \"a\",\n  \"z\": 1,\n  \"a\": { <-- a sorted before obj, because alphabetical, and both objects\n    \"b\": 1,\n    \"a\": {  <-- note that a comes after b, because it's an object\n      \"nested\": true\n    }\n  },\n  \"obj\": {\n    \"b\": \"x\",\n    \"a\": {}\n  }\n}\n*/\n\n// specify an array of keys if you have some that you prefer\n// to be sorted in a specific order.  preferred keys come before\n// any other keys, and in the order specified, but objects are\n// still sorted AFTER scalars, so the preferences only apply\n// when both values are objects or both are non-objects.\nconsole.log(stringify(obj, ['z', 'yy', 'obj']))\n/* output\n{\n  \"z\": 1, <-- z comes before other scalars\n  \"yy\": \"a\", <-- yy comes after z, but before other scalars\n  \"y\": \"z\", <-- then all the other scalar values\n  \"obj\": { <-- obj comes before other objects, but after scalars\n    \"b\": \"x\",\n    \"a\": {}\n  },\n  \"a\": {\n    \"b\": 1,\n    \"a\": {\n      \"nested\": true\n    }\n  }\n}\n*/\n\n// can also specify a replacer or indent value like with JSON.stringify\n// this turns all values with an 'a' key into a doggo meme from 2011\nconst replacer = (key, val) =>\n  key === 'a' ? { hello: '???? yes', 'this is': '????', ...val } : val\n\nconsole.log(stringify(obj, replacer, '????????'))\n\n/* output:\n{\n????????\"y\": \"z\",\n????????\"yy\": \"a\",\n????????\"z\": 1,\n????????\"a\": {\n????????????????\"b\": 1,\n????????????????\"hello\": \"???? yes\",\n????????????????\"this is\": \"????\",\n????????????????\"a\": {\n????????????????????????\"hello\": \"???? yes\",\n????????????????????????\"nested\": true,\n????????????????????????\"this is\": \"????\"\n????????????????}\n????????},\n????????\"obj\": {\n????????????????\"b\": \"x\",\n????????????????\"a\": {\n????????????????????????\"hello\": \"???? yes\",\n????????????????????????\"this is\": \"????\"\n????????????????}\n????????}\n}\n*/\n```\n","_attachments":{},"homepage":"https://github.com/isaacs/json-stringify-nice#readme","bugs":{"url":"https://github.com/isaacs/json-stringify-nice/issues"},"license":"ISC"}