{"name":"json-stringify-pretty-compact","version":"1.2.0","author":{"name":"Simon Lydell"},"license":"MIT","description":"The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/lydell/json-stringify-pretty-compact.git"},"files":["index.js","index.d.ts"],"keywords":["JSON","stringify","pretty","print","pretty-print","compact","indent","format","formatter"],"scripts":{"lint":"standard","unit":"mocha --ui tdd","test":"npm run lint && npm run unit"},"devDependencies":{"chai":"^4.1.2","mocha":"^4.1.0","standard":"^10.0.3"},"gitHead":"4dd6aa7631fbc81c03effa51d8d7063cad1ff4b3","bugs":{"url":"https://github.com/lydell/json-stringify-pretty-compact/issues"},"homepage":"https://github.com/lydell/json-stringify-pretty-compact#readme","_id":"json-stringify-pretty-compact@1.2.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"integrity":"sha512-/11Pj1OyX814QMKO7K8l85SHPTr/KsFxHp8GE2zVa0BtJgGimDjXHfM3FhC7keQdWDea7+nXf+f1de7ATZcZkQ==","shasum":"0bc316b5e6831c07041fc35612487fb4e9ab98b8","tarball":"http://registry-npm.ywwl.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.2.0.tgz","fileCount":6,"unpackedSize":7715,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa3NfOCRA9TVsSAnZWagAAVD4P/2tkb4AkEbvWdbSw8vGL\nOZBRQE4bVqiP+TWyd+7lh7HiIsSPHjdZXQ1pzjPAEjua0hTsRYYLPtXl7peX\nKcX36M5uQVMrVL6spuMcmn0CZHOqtmFebO8E+Sgpa1R/dEL7iNgzUQbn4PKb\nTNpIMpAVQmArBiTiA96A2S9Ii8ounHay4EylOlOfAo0rMGBkLlialEy9O4vq\n4zwqd6bf98oP28lI59nyB/FcKO9HwA64ksrQ0wsVQbIbsBwt41Ihm8TpiS8H\n1yVegkwZ+cn+YFgrzNo4mAN/UuOq/3hTabBlDPXizb00Lo7y90wtJSyODbIM\nQGyh5+vLOi7/NJtkrPzN7EbHG8TK8ERTSfYS6SB86dLVCFKk2VoAii6sDi6W\nLAlXwZL4bpliC0xl0HwgF352UMx3lZ2uHUAWK6/PiElsecY2epoDN4ikrIB2\n47443o02idNiXEEjZ9LeUzRTe9u8Swot1xCRuT/KISxGiY8vAw0v5Yg4eTAN\nUO8a2mPWesMxgCaTVvC8iBnGhdVDnfagbQFLTO8pzvQ5ol7+VO0e6/gJhmTB\nsm59u1nEixoq9Vx4bwBgzPW3OEX4wtrT9sobr/QEq52ZiRLXaXCERw/dJT7d\n+LmkP+JfVjveB8i+RAFRRuEelQBdnnM+KvGGqVU+/9aVok8DCzQDD0ZUpYL9\nIZ4p\r\n=p5Sz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICeIYoazE5ivhx/Sn50T0Ikq99np5wBgydufAagGOP9bAiAm2vfOzJpnLz5IcHFwu0tHmgXzzbb3YtJA5/9gXL4k/g=="}],"size":3679,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.2.0.tgz"},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_1.2.0_1524422604990_0.22994909187752577"},"_hasShrinkwrap":false,"readme":"# json-stringify-pretty-compact\n\nThe output of [JSON.stringify] comes in two flavors: _compact_ and _pretty._ The former is usually too compact to be read by humans, while the latter sometimes is too spacious. This module trades performance for a compromise between the two. The result is a _pretty_ compact string, where “pretty” means both “kind of” and “nice”.\n\n<!-- prettier-ignore -->\n```json\n{\n  \"bool\": true,\n  \"short array\": [1, 2, 3],\n  \"long array\": [\n    {\"x\": 1, \"y\": 2},\n    {\"x\": 2, \"y\": 1},\n    {\"x\": 1, \"y\": 1},\n    {\"x\": 2, \"y\": 2}\n  ]\n}\n```\n\nWhile the “pretty” mode of [JSON.stringify] puts every item of arrays and objects on its own line, this module puts the whole array or object on a single line, unless the line becomes too long (the default maximum is 80 characters). Making arrays and objects multi-line is the only attempt made to enforce the maximum line length; if that doesn’t help then so be it.\n\n## Installation\n\n```\nnpm install json-stringify-pretty-compact\n```\n\n```js\nimport stringify from \"json-stringify-pretty-compact\";\n```\n\n> **Note:** This is an [ESM only package]. (I haven’t written that gist, but it’s a great resource.)\n>\n> If you need CommonJS, install version 3.0.0. You won’t be missing out on anything: This package is _done._ No more features will be added, and no bugs have been found in years.\n\n## `stringify(obj, options = {})`\n\nIt’s like `JSON.stringify(obj, options.replacer, options.indent)`, except that objects and arrays are on one line if they fit (according to `options.maxLength`).\n\n`options`:\n\n- indent: Defaults to 2. Works exactly like the third parameter of [JSON.stringify].\n- maxLength: Defaults to 80. Lines will be tried to be kept at maximum this many characters long.\n- replacer: Defaults to undefined. Works exactly like the second parameter of [JSON.stringify].\n\n`stringify(obj, {maxLength: 0, indent: indent})` gives the exact same result as `JSON.stringify(obj, null, indent)`. (However, if you use a `replacer`, integer keys might be moved first.)\n\n`stringify(obj, {maxLength: Infinity})` gives the exact same result as `JSON.stringify(obj)`, except that there are spaces after colons and commas.\n\n**Want more options?** Check out [@aitodotai/json-stringify-pretty-compact]!\n\n## License\n\n[MIT](LICENSE).\n\n[@aitodotai/json-stringify-pretty-compact]: https://www.npmjs.com/package/@aitodotai/json-stringify-pretty-compact\n[json.stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n[esm only package]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n","publish_time":1524422605058,"_cnpm_publish_time":1524422605058,"dist-tags":{"latest":"4.0.0"}}