{"_id":"json-stringify-pretty-compact","_rev":"2999625","name":"json-stringify-pretty-compact","description":"The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"lydell","email":""}],"time":{"modified":"2023-08-29T08:48:55.000Z","created":"2014-11-01T10:31:03.392Z","4.0.0":"2022-05-14T21:34:18.394Z","3.0.0":"2021-02-20T21:53:58.133Z","2.0.0":"2019-02-02T13:16:12.250Z","1.2.0":"2018-04-22T18:43:25.058Z","1.1.0":"2018-01-12T20:01:20.568Z","1.0.4":"2017-04-29T06:44:38.386Z","1.0.3":"2017-03-30T06:23:37.713Z","1.0.2":"2016-09-08T16:06:05.866Z","1.0.1":"2014-11-03T19:45:18.225Z","1.0.0":"2014-11-01T10:31:03.392Z"},"users":{"brugnara":true,"farskipper":true,"nilslikestacos":true,"bplok20010":true,"sopepos":true},"author":{"name":"Simon Lydell"},"repository":{"type":"git","url":"git+https://github.com/lydell/json-stringify-pretty-compact.git"},"versions":{"4.0.0":{"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":{"shasum":"cf4844770bddee3cb89a6170fe4b00eee5dbf1d4","size":3406,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-4.0.0.tgz"},"_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"directories":{},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_4.0.0_1652564058220_0.9888728988243947"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-14T21:34:21.960Z","publish_time":1652564058394,"_cnpm_publish_time":1652564058394},"3.0.0":{"name":"json-stringify-pretty-compact","version":"3.0.0","author":{"name":"Simon Lydell"},"license":"MIT","description":"The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.","type":"commonjs","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 . && jest --coverage","prepublishOnly":"npm test"},"devDependencies":{"eslint":"7.20.0","eslint-plugin-jest":"24.1.5","jest":"26.6.3","prettier":"2.2.1"},"gitHead":"5810537005be9fec0b15d64edcf49728d26e3776","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@3.0.0","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"shasum":"f71ef9d82ef16483a407869556588e91b681d9ab","size":3986,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-3.0.0.tgz"},"_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"directories":{},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_3.0.0_1613858037957_0.6438948907361368"},"_hasShrinkwrap":false,"publish_time":1613858038133,"_cnpm_publish_time":1613858038133},"2.0.0":{"name":"json-stringify-pretty-compact","version":"2.0.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"},"keywords":["JSON","stringify","pretty","print","pretty-print","compact","indent","format","formatter"],"scripts":{"eslint":"eslint .","eslint:fix":"npm run eslint -- --fix","prettier":"prettier --write \"**/*.{md,ts}\"","jest":"jest","coverage":"jest --coverage","test":"npm run eslint && npm run coverage","prepublishOnly":"npm test"},"devDependencies":{"eslint":"5.13.0","eslint-config-lydell":"13.0.0","eslint-plugin-jest":"22.2.2","eslint-plugin-prettier":"3.0.1","jest":"24.0.0","prettier":"1.16.3"},"gitHead":"29d6f1aa60ca4f706b80148817627d1760f60f5e","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@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"e77c419f52ff00c45a31f07f4c820c2433143885","size":4191,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-2.0.0.tgz"},"maintainers":[{"name":"lydell","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_2.0.0_1549113372071_0.10022697466076536"},"_hasShrinkwrap":false,"publish_time":1549113372250,"_cnpm_publish_time":1549113372250},"1.2.0":{"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":{"shasum":"0bc316b5e6831c07041fc35612487fb4e9ab98b8","size":3679,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.2.0.tgz"},"maintainers":[{"name":"lydell","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact_1.2.0_1524422604990_0.22994909187752577"},"_hasShrinkwrap":false,"publish_time":1524422605058,"_cnpm_publish_time":1524422605058},"1.1.0":{"name":"json-stringify-pretty-compact","version":"1.1.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"],"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":"205e38a199171d4d96459284d0d41e3949220154","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.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"4fa5b898f61a287d64828691baa822a41f3ad5ab","size":3539,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.1.0.tgz"},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-stringify-pretty-compact-1.1.0.tgz_1515787279615_0.633592565311119"},"directories":{},"publish_time":1515787280568,"_hasShrinkwrap":false,"_cnpm_publish_time":1515787280568},"1.0.4":{"name":"json-stringify-pretty-compact","version":"1.0.4","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"],"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":"^3.5.0","mocha":"^3.2.0","standard":"^9.0.2"},"gitHead":"cdd041e16368b29d5c6962e42555e42f8ab8b21c","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.0.4","_shasum":"d5161131be27fd9748391360597fcca250c6c5ce","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"d5161131be27fd9748391360597fcca250c6c5ce","size":3340,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.0.4.tgz"},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/json-stringify-pretty-compact-1.0.4.tgz_1493448277773_0.4768994541373104"},"directories":{},"publish_time":1493448278386,"_cnpm_publish_time":1493448278386,"_hasShrinkwrap":false},"1.0.3":{"name":"json-stringify-pretty-compact","version":"1.0.3","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"],"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":"^3.5.0","mocha":"^3.2.0","standard":"^9.0.2"},"gitHead":"d9fa5f743598dce3c007d50d5f41b4720cf0e724","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.0.3","_shasum":"f7e349404d35f0b3ee07a2f96213f3a1ae9e92f7","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"f7e349404d35f0b3ee07a2f96213f3a1ae9e92f7","size":3262,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.0.3.tgz"},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/json-stringify-pretty-compact-1.0.3.tgz_1490855015814_0.8736686070915312"},"directories":{},"publish_time":1490855017713,"_hasShrinkwrap":false,"_cnpm_publish_time":1490855017713},"1.0.2":{"name":"json-stringify-pretty-compact","version":"1.0.2","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"],"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":"^3.5.0","mocha":"^3.0.2","standard":"^8.0.0"},"gitHead":"8ded1472a1a94d3dfa07886ee8e9c52dc5781901","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.0.2","_shasum":"abe8ae193feb19020dfeec74363be03d65821a31","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"dist":{"shasum":"abe8ae193feb19020dfeec74363be03d65821a31","size":2325,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.0.2.tgz"},"maintainers":[{"name":"lydell","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/json-stringify-pretty-compact-1.0.2.tgz_1473350764580_0.6148994627874345"},"directories":{},"publish_time":1473350765866,"_cnpm_publish_time":1473350765866,"_hasShrinkwrap":false},"1.0.1":{"name":"json-stringify-pretty-compact","version":"1.0.1","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":"https://github.com/lydell/json-stringify-pretty-compact"},"keywords":["JSON","stringify","pretty","print","pretty-print","compact","indent","format","formatter"],"scripts":{"test":"mocha"},"devDependencies":{"mocha":"^2.0.1","chai":"^1.9.2"},"gitHead":"dff719c8c6e9e2c4e97b666865943f4f442af423","bugs":{"url":"https://github.com/lydell/json-stringify-pretty-compact/issues"},"homepage":"https://github.com/lydell/json-stringify-pretty-compact","_id":"json-stringify-pretty-compact@1.0.1","_shasum":"26a616a0b1a77157f1d5b1a34c0ecbe6e1177715","_from":".","_npmVersion":"2.1.6","_nodeVersion":"0.10.33","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":""}],"dist":{"shasum":"26a616a0b1a77157f1d5b1a34c0ecbe6e1177715","size":5609,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.0.1.tgz"},"directories":{},"publish_time":1415043918225,"_cnpm_publish_time":1415043918225,"_hasShrinkwrap":false},"1.0.0":{"name":"json-stringify-pretty-compact","version":"1.0.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":"https://github.com/lydell/json-stringify-pretty-compact"},"keywords":["JSON","stringify","pretty","print","pretty-print","compact","indent"],"scripts":{"test":"mocha"},"devDependencies":{"mocha":"^2.0.1","chai":"^1.9.2"},"gitHead":"e392dd7b515c4df34fb4b4f0a52c9f90bcc04a88","bugs":{"url":"https://github.com/lydell/json-stringify-pretty-compact/issues"},"homepage":"https://github.com/lydell/json-stringify-pretty-compact","_id":"json-stringify-pretty-compact@1.0.0","_shasum":"3ab1ae3783d4f90b23e24de13cd4aae50a0d5f19","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"lydell","email":"simon.lydell@gmail.com"},"maintainers":[{"name":"lydell","email":""}],"dist":{"shasum":"3ab1ae3783d4f90b23e24de13cd4aae50a0d5f19","size":5272,"noattachment":false,"key":"/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/json-stringify-pretty-compact/download/json-stringify-pretty-compact-1.0.0.tgz"},"directories":{},"publish_time":1414837863392,"_cnpm_publish_time":1414837863392,"_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","_attachments":{},"homepage":"https://github.com/lydell/json-stringify-pretty-compact#readme","bugs":{"url":"https://github.com/lydell/json-stringify-pretty-compact/issues"},"license":"MIT"}