{"_id":"@base2/pretty-print-object@1.0.4","bugs":{"url":"https://github.com/Chris-Baker/pretty-print-object/issues"},"dist":{"shasum":"d68b3f18dcd1ecbb4a41ff3e4cf2a1746b5da924","tarball":"http://registry-npm.ywwl.com/@base2/pretty-print-object/download/@base2/pretty-print-object-1.0.4.tgz","fileCount":5,"integrity":"sha512-ol/E9YYLhsKfNeyhxH46KxGTb0tm1dd/1lH8dSsspOsSDWdzbz0Dft6GG23sI7aCZiVo1d+q+AVvXC/KgaMSeA==","signatures":[{"sig":"MEQCIBWdSwVNrfiOhxJjki6yuNtVRKtL0O6dZBzed2UzHiC/AiAcmsVadwTTGUX336EVIbjAYUFSBwPrUx1Ey3udIlZ73A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDOzUzV2g2iyM19OwEbw7qbX2ckBtvB7Y8cN4vuBWdoqgIhAPQOa8nlvZTQzsiJrRNamzrbycoxBA/VZnGxUcWq2QxB"}],"unpackedSize":16112,"size":5389,"noattachment":false,"key":"/@base2/pretty-print-object/-/@base2/pretty-print-object-1.0.4.tgz"},"main":"./dist/index.js","name":"@base2/pretty-print-object","types":"./dist/index.d.ts","author":{"name":"Chris Baker"},"gitHead":"de3462ad758fb8d5829a8db6300204ea04af9d4a","license":"BSD-2-Clause","scripts":{"lint":"eslint .","test":"npm run build && jest --runInBand","build":"node scripts/build.mjs && tsc -p tsconfig.json","check":"npm run lint && npm run format:check && npm run typecheck && npm test","format":"prettier --write .","prepack":"npm run build","typecheck":"tsc -p tsconfig.test.json --noEmit","format:check":"prettier --check .","check:dependencies":"node scripts/check-dependency-age.mjs && npm audit --audit-level=low"},"version":"1.0.4","_npmUser":{"name":"chris-baker","email":"lxufimdu@pm.me"},"homepage":"https://github.com/Chris-Baker/pretty-print-object#readme","keywords":["object","stringify","pretty","print","dump","format","type","json"],"overrides":{"@istanbuljs/load-nyc-config":{"js-yaml":"4.3.2"}},"repository":{"url":"git+https://github.com/Chris-Baker/pretty-print-object.git","type":"git"},"_npmVersion":"11.16.0","description":"Convert an object or array into a formatted string","directories":{},"maintainers":[{"name":"chris-baker","email":"lxufimdu@pm.me"}],"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^30.5.2","acorn":"^8.18.0","eslint":"^10.11.0","prettier":"^3.9.9","@swc/core":"^1.16.12","@swc/jest":"^0.2.39","@eslint/js":"^10.0.1","typescript":"~6.0.3","@types/jest":"^30.0.0","@types/node":"^24.19.0","typescript-eslint":"^8.71.0","eslint-config-prettier":"^10.1.8"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pretty-print-object_1.0.4_1792328229749_0.14652159250811492"},"readme":"# Pretty print object\n\n[![License][license-image]][license-url] [![CI][ci-image]][ci-url]\n\n> Convert an object or array into a formatted string\n\nThis is a re-write of [stringify-object] in Typescript, modified to inline the dependencies and make it compatible with ES5 out of the box.\n\nUseful for when you want to get the string representation of an object in a formatted way.\n\nIt also handles circular references and lets you specify quote type.\n\n## Install\n\n```\n$ npm install @base2/pretty-print-object\n```\n\n## Usage\n\n```js\nimport { prettyPrint } from '@base2/pretty-print-object';\n\nconst obj = {\n    foo: 'bar',\n    arr: [1, 2, 3],\n    nested: {\n        hello: 'world'\n    }\n};\n\nconst pretty = prettyPrint(obj, {\n    indent: '  ',\n    singleQuotes: false\n});\n\nconsole.log(pretty);\n/*\n{\n  foo: \"bar\",\n  arr: [\n    1,\n    2,\n    3\n  ],\n  nested: {\n    hello: \"world\"\n  }\n}\n*/\n```\n\n## API\n\n### prettyPrint(input, [options])\n\nInvalid dates are printed as `Invalid Date` instead of throwing an exception. Valid dates retain the `new Date('...')` representation.\n\nCircular references will be replaced with `\"[Circular]\"`.\n\nObject keys are only quoted when necessary, for example, `{'foo-bar': true}`.\n\n#### input\n\nType: `Object` `Array`\n\n#### options\n\nType: `Object`\n\n##### indent\n\nType: `string`<br>\nDefault: `\\t`\n\nPreferred indentation.\n\n##### singleQuotes\n\nType: `boolean`<br>\nDefault: `true`\n\nSet to false to get double-quoted strings.\n\n##### filter(obj, prop)\n\nType: `Function`\n\nExpected to return a `boolean` of whether to include the property `prop` of the object `obj` in the output.\n\n##### transform(obj, prop, originalResult)\n\nType: `Function`<br>\nDefault: `undefined`\n\nExpected to return a `string` that transforms the string that resulted from stringifying `obj[prop]`. This can be used to detect special types of objects that need to be stringified in a particular way. The `transform` function might return an alternate string in this case, otherwise returning the `originalResult`.\n\nHere's an example that uses the `transform` option to mask fields named \"password\":\n\n```js\nimport { prettyPrint } from '@base2/pretty-print-object';\n\nconst obj = {\n    user: 'becky',\n    password: 'secret'\n};\n\nconst pretty = prettyPrint(obj, {\n    transform: (obj, prop, originalResult) => {\n        if (prop === 'password') {\n            return originalResult.replace(/\\w/g, '*');\n        }\n\n        return originalResult;\n    }\n});\n\nconsole.log(pretty);\n/*\n{\n    user: 'becky',\n    password: '******'\n}\n*/\n```\n\n##### inlineCharacterLimit\n\nType: `number`\n\nWhen set, will inline values up to `inlineCharacterLimit` length for the sake of more terse output.\n\nFor example, given the example at the top of the README:\n\n```js\nimport { prettyPrint } from '@base2/pretty-print-object';\n\nconst obj = {\n    foo: 'bar',\n    arr: [1, 2, 3],\n    nested: {\n        hello: 'world'\n    }\n};\n\nconst pretty = prettyPrint(obj, {\n    indent: '  ',\n    singleQuotes: false,\n    inlineCharacterLimit: 12\n});\n\nconsole.log(pretty);\n/*\n{\n  foo: \"bar\",\n  arr: [1, 2, 3],\n  nested: {\n    hello: \"world\"\n  }\n}\n*/\n```\n\nAs you can see, `arr` was printed as a one-liner because its string was shorter than 12 characters.\n\n[stringify-object]: https://www.npmjs.com/package/stringify-object\n[ci-image]: https://github.com/Chris-Baker/pretty-print-object/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/Chris-Baker/pretty-print-object/actions/workflows/ci.yml\n[license-url]: https://opensource.org/licenses/BSD-2-Clause\n[license-image]: https://img.shields.io/badge/License-BSD%202--Clause-orange.svg\n","publish_time":1792328229849,"_cnpm_publish_time":1792328229849,"dist-tags":{"latest":"1.0.4"}}