{"name":"@base2/pretty-print-object","version":"1.0.2","description":"Convert an object or array into a formatted string","repository":{"type":"git","url":"git+https://github.com/Chris-Baker/pretty-print-object.git"},"main":"./dist/index.js","scripts":{"build":"tsc","test":"jest --verbose"},"keywords":["object","stringify","pretty","print","dump","format","type","json"],"author":{"name":"Chris Baker"},"license":"BSD-2-Clause","devDependencies":{"@babel/core":"^7.4.3","@babel/plugin-transform-runtime":"^7.4.3","@babel/preset-env":"^7.4.3","@babel/preset-typescript":"^7.3.3","@babel/runtime":"^7.5.5","@types/jest":"^24.0.13","@typescript-eslint/eslint-plugin":"^5.21.0","@typescript-eslint/parser":"^5.21.0","eslint":"^6.2.2","eslint-config-prettier":"^6.1.0","eslint-plugin-prettier":"^3.1.0","jest":"^28.0.2","prettier":"^1.15.3","pretty-quick":"^1.8.0","typescript":"^4.3.5"},"types":"./dist/index.d.ts","gitHead":"94c47930f45e0746b715d538075ec70fd92813ae","bugs":{"url":"https://github.com/Chris-Baker/pretty-print-object/issues"},"homepage":"https://github.com/Chris-Baker/pretty-print-object#readme","_id":"@base2/pretty-print-object@1.0.2","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-rBha0UDfV7EmBRjWrGG7Cpwxg8WomPlo0q+R2so47ZFf9wy4YKJzLuHcVa0UGFjdcLZj/4F/1FNC46GIQhe7sA==","shasum":"e30192222fd13e3c1e97040163d6628a95f70844","tarball":"http://registry-npm.ywwl.com/@base2/pretty-print-object/download/@base2/pretty-print-object-1.0.2.tgz","fileCount":5,"unpackedSize":13360,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICZjWBa6X6s03APvqNL5pyuIcsSAZa12kPcckkzdxbkcAiBVnNn0vQtRC3/sWri9hXkG4dyKQrCAFOB6sL+6RmXWzA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaod3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrCZw/9H1dsbW/G0hqlJwPQ4Fg/XdtQeDY6RTdvsSKp/IaZLR3MGjAK\r\nj2I4AwdLyD2m2kMUuCbuonZo0v7TCwO9XsHfUjhbmTtl9hnBxqDJFs29+K+H\r\nDQDN/KxNZadV3mNC/q4lyhiy3l9shsLXhDrKkMgcf952FcXO9/90z8swllwR\r\n1S4av9JbqSwhRcsKfIGAwk6ZgDoyMIIAn4FwEH2DrXHy6XPFGwiZAuU+m2aR\r\n4Gg6h5I9K/WAybu9kTVk7XJDOtEFYgXuR4HMaNp4NzVNdj/L/jEs5aFsjXZz\r\nS6XdFQfKc/sMwU47lFB73695cfnnP9CZQgVZ0B4AFts89vDaVWR9nVgKGvTW\r\nQCk2WTUFuwtWfRQdVw+pam6g8JY114CPLuqSK0wXe4SKnypOUtpBjK4NQHoN\r\njWLjpeOHln86VDlHr5tpauWIxI+SC8RwLKXmZBGvOR03YCiI9g3RfZudfEP6\r\nLRcXcv0F/ug9jQNDfiLZpgyMQlpNd7Ynzg/7HKqpCg2hjmkJ8iBxD1bMmqyQ\r\nACRySqPLHb306sD5Nv0po6WyPr7hNjYFUYKnTRa8AH3I0sY8IocJ1pZlT/xS\r\npo7QR5zRrE6iMrpkOxcOsynHdOaMIi48oOo6mbjlFrbG/N8yPP+b3XalnaRP\r\nRY6K7mpo49W6Sm+7oxHKyzoMrw/D8IU0XlM=\r\n=Uqtv\r\n-----END PGP SIGNATURE-----\r\n","size":4545,"noattachment":false,"key":"/@base2/pretty-print-object/-/@base2/pretty-print-object-1.0.2.tgz"},"_npmUser":{"name":"chris-baker","email":"lxufimdu@pm.me"},"directories":{},"maintainers":[{"name":"chris-baker","email":"lxufimdu@pm.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pretty-print-object_1.0.2_1651148662893_0.9223263200643106"},"_hasShrinkwrap":false,"readme":"# Pretty print object\n[![License][license-image]][license-url] ![coverage-badge-green]\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\n## Install\n\n```\n$ npm install @base2/pretty-print-object\n```\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\n## API\n\n### prettyPrint(input, [options])\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\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[coverage-badge-green]: https://img.shields.io/badge/Coverage-100%25-brightgreen.svg\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":1651148663087,"_cnpm_publish_time":1651148663087,"dist-tags":{"latest":"1.0.4"}}