{"name":"json-stringify-pretty-compact","version":"4.0.0","author":{"name":"Simon Lydell"},"license":"MIT","description":"The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.","type":"module","exports":"./index.js","types":"index.d.ts","repository":{"type":"git","url":"git+https://github.com/lydell/json-stringify-pretty-compact.git"},"keywords":["JSON","stringify","pretty","print","pretty-print","compact","indent","format","formatter"],"scripts":{"test":"eslint . --report-unused-disable-directives && prettier --check . && node --test","prepublishOnly":"npm test"},"devDependencies":{"eslint":"8.15.0","prettier":"2.6.2"},"gitHead":"4001a1217b358f1d2aff2654fe1593d62d131195","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@4.0.0","_nodeVersion":"18.1.0","_npmVersion":"8.8.0","dist":{"integrity":"sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==","shasum":"cf4844770bddee3cb89a6170fe4b00eee5dbf1d4","tarball":"http://registry-npm.ywwl.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-4.0.0.tgz","fileCount":5,"unpackedSize":7412,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUY+B+qSk71BAA5MwTGkeTMtdAjYmxQMuicURMZGMeBQIhAOXGijZt2lTmLfw1Y7jzGxqjDPwLWSt84zVf8WkxjBA+"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJigCBaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpLHw/+NiCoLJ+IIsc091y5UZc4Ia5sQ1vv3VVzGbzqDdWZi0xq1OTI\r\nQvfGTvwh8sflR8VOgnH5HeFNx+W+zqCwC6WFQwhuMH+3nwgb+d0bhUC0hv+Q\r\nQ6NpD33sMCw0zzgr9QQYZEy9iIl0MvknjfQUK5DkqVq2BlAr3OG5qUALCEnW\r\nAjM9A4fQoXTe0gt1RdQRNd2kizNC4RbCVVZP9YJJ1dL66h4FXGElUx3pN+tp\r\ndvURu09NHeqz6npDqXr2KINAkPLVnQputBSkbjSWFH/rQgMOtcF1WctQ6ntK\r\nvaj/D3YFCW3+Ua45PEU1j8Jiyr5uVN8dFmAoxh5pzAPjc7erkhB01RlDWfHb\r\ncqzcTZ4/d7vJiuXVjIYSs0/eYtyYnZY+Vv8+n9CJQt7IZAnpjNkw4RfPEnDj\r\n5Y1UwQV6ETpOc+AGoG7D2ML6xfVl1UbeM/VcAzDRK/jWZpXJ7r/R7mzyLUJA\r\nQJ8IfLAul+YTCVr4BNP6Rj9SWVpmQRyS0WCLRQcOiqPr8+Kb+YeCRue0s/Td\r\nBgP3ppTCLht22YN3/NyC3+SqHJA0GfOlWAOxxs7btwpvjEd6+RVoCbAEN0A9\r\nKVvibpmdU4SFvhVAhkp2MMBYqkUVtfdJdIbY9Hu+qc1yG8/RrvNs96qBrMaQ\r\nICfKSRaiFhjXlqkNC0nEnXS/Nyt64uzHsx0=\r\n=0QPI\r\n-----END PGP SIGNATURE-----\r\n","size":3406,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz"},"_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"directories":{},"maintainers":[{"name":"lydell","email":"simon.lydell@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_4.0.0_1652564058220_0.9888728988243947"},"_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":1652564058394,"_cnpm_publish_time":1652564058394,"dist-tags":{"latest":"4.0.0"}}