{"name":"stringify-object","version":"6.0.0","keywords":["object","stringify","pretty","print","dump","format","type","json"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"BSD-2-Clause","_id":"stringify-object@6.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/stringify-object#readme","bugs":{"url":"https://github.com/sindresorhus/stringify-object/issues"},"xo":{"ignores":["test/fixtures/*.js"]},"dist":{"shasum":"1f6a11ada4b8619657c1780816f278a186b5bcac","tarball":"http://registry-npm.ywwl.com/stringify-object/download/stringify-object-6.0.0.tgz","fileCount":4,"integrity":"sha512-6f94vIED6vmJJfh3lyVsVWxCYSfI5uM+16ntED/Ql37XIyV6kj0mRAAiTeMMc/QLYIaizC3bUprQ8pQnDDrKfA==","signatures":[{"sig":"MEQCIGztbUKe/QPnNCHX6pnnzHBmlFMJQ2CHgiMtikxUxBvMAiBEKOEBCYB8sUFVNmCXfsQhjWfMvxDFjsHYSnEZZxvTDg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10459,"size":3999,"noattachment":false,"key":"/stringify-object/-/stringify-object-6.0.0.tgz"},"type":"module","engines":{"node":">=20"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"dd7c193e7d343ae4b86019f9104d382b30541da8","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/stringify-object.git","type":"git"},"_npmVersion":"10.9.2","description":"Stringify an object/array like JSON.stringify just without all the double-quotes","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","dependencies":{"is-obj":"^3.0.0","is-regexp":"^3.1.0","is-identifier":"^1.0.1","get-own-enumerable-keys":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^1.2.2","ava":"^6.4.1"},"_npmOperationalInternal":{"tmp":"tmp/stringify-object_6.0.0_1757284121531_0.6084830489419446","host":"s3://npm-registry-packages-npm-production"},"readme":"# stringify-object\n\n> Stringify an object/array like JSON.stringify just without all the double-quotes\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```sh\nnpm install stringify-object\n```\n\n## Usage\n\n```js\nimport stringifyObject from 'stringify-object';\n\nconst object = {\n\tfoo: 'bar',\n\t'arr': [1, 2, 3],\n\tnested: {\n\t\thello: \"world\"\n\t}\n};\n\nconst pretty = stringifyObject(object, {\n\tindent: '  ',\n\tsingleQuotes: 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// Also works with Map and Set\nconst map = new Map([['key', 'value']]);\nconsole.log(stringifyObject(map));\n//=> new Map([\n//=>   ['key', 'value']\n//=> ])\n```\n\n## API\n\n### stringifyObject(input, options?)\n\nCircular references will be replaced with `\"[Circular]\"`.\n\nObject keys are only quoted when necessary, for example, `{'foo-bar': true}`.\n\nAn own `__proto__` key is never included in the output, as emitting it would set the prototype instead of creating a property when the output is evaluated.\n\n#### input\n\nType: `object | Array | Map | Set`\n\n#### options\n\nType: `object`\n\n##### indent\n\nType: `string`\\\nDefault: `\\t`\n\nPreferred indentation.\n\n##### singleQuotes\n\nType: `boolean`\\\nDefault: `true`\n\nSet to `false` to get double-quoted strings.\n\n##### filter(object, property)\n\nType: `Function`\n\nExpected to return a `boolean` of whether to include the property `property` of the object `object` in the output.\n\n##### transform(object, property, originalResult)\n\nType: `Function`\\\nDefault: `undefined`\n\nExpected to return a `string` that transforms the string that resulted from stringifying `object[property]`. 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\nWhen stringifying a `Map` or `Set`, `object` is the `Map`/`Set`, `property` is the entry's key (`Map`) or value (`Set`), and `originalResult` is the stringified value.\n\nHere's an example that uses the `transform` option to mask fields named \"password\":\n\n```js\nimport stringifyObject from 'stringify-object';\n\nconst object = {\n\tuser: 'becky',\n\tpassword: 'secret'\n};\n\nconst pretty = stringifyObject(object, {\n\ttransform: (object, property, originalResult) => {\n\t\tif (property === 'password') {\n\t\t\treturn originalResult.replace(/\\w/g, '*');\n\t\t}\n\n\t\treturn originalResult;\n\t}\n});\n\nconsole.log(pretty);\n/*\n{\n\tuser: 'becky',\n\tpassword: '******'\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 stringifyObject from 'stringify-object';\n\nconst object = {\n\tfoo: 'bar',\n\t'arr': [1, 2, 3],\n\tnested: {\n\t\thello: \"world\"\n\t}\n};\n\nconst pretty = stringifyObject(object, {\n\tindent: '  ',\n\tsingleQuotes: false,\n\tinlineCharacterLimit: 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","publish_time":1757284121706,"_cnpm_publish_time":1757284121706,"dist-tags":{"latest":"7.0.0"}}