{"name":"stringify-object","version":"7.0.0","description":"Stringify an object/array like JSON.stringify just without all the double-quotes","license":"BSD-2-Clause","repository":{"type":"git","url":"git+https://github.com/sindresorhus/stringify-object.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=22"},"scripts":{"test":"xo && node --test test/index.js"},"keywords":["object","stringify","pretty","print","dump","format","type","json"],"dependencies":{"get-own-enumerable-keys":"^1.0.0","is-identifier":"^1.0.1","is-obj":"^3.0.0","is-regexp":"^3.1.0","quote-js-string":"^0.1.0"},"devDependencies":{"xo":"^3.0.2"},"xo":{"ignores":["test/fixtures/*.js"]},"gitHead":"c359727290822d9cabf7c07fb86cdb08701c1010","types":"./index.d.ts","_id":"stringify-object@7.0.0","bugs":{"url":"https://github.com/sindresorhus/stringify-object/issues"},"homepage":"https://github.com/sindresorhus/stringify-object#readme","_nodeVersion":"22.22.3","_npmVersion":"11.18.0","dist":{"integrity":"sha512-RQU1n5OVVXD9fhww7e/rqiKdMa+LPMFLz0zDTbZ+KUjMfiMmh9soT8aw5iwvCGVquUJOodoinyv3VECyY7aFBQ==","shasum":"7f6229afd65f68db29a31770e0d03e70d1a798fc","tarball":"http://registry-npm.ywwl.com/stringify-object/download/stringify-object-7.0.0.tgz","fileCount":5,"unpackedSize":12893,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHXVE++TLJfv4+JcAQ715MLQhDRh/hxNaD4ExPwg5eKEAiEA61brhU3gVNIXoTaNADtdifsdrXLfaAqoCuAWHVca+SU="}],"size":4442,"noattachment":false,"key":"/stringify-object/-/stringify-object-7.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/stringify-object_7.0.0_1783031078046_0.22936393017393897"},"_hasShrinkwrap":false,"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":1783031078195,"_cnpm_publish_time":1783031078195,"dist-tags":{"latest":"7.0.0"}}