{"id":15634512,"url":"https://github.com/blakeembrey/javascript-stringify","last_synced_at":"2025-05-16T06:08:00.352Z","repository":{"id":19143531,"uuid":"22373736","full_name":"blakeembrey/javascript-stringify","owner":"blakeembrey","description":"Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`","archived":false,"fork":false,"pushed_at":"2023-12-07T08:58:14.000Z","size":357,"stargazers_count":144,"open_issues_count":8,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-04T16:02:40.295Z","etag":null,"topics":["code","javascript","javascript-stringify","json","serialize","stringify"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blakeembrey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-29T08:57:44.000Z","updated_at":"2025-04-08T00:43:56.000Z","dependencies_parsed_at":"2024-06-18T12:43:44.078Z","dependency_job_id":null,"html_url":"https://github.com/blakeembrey/javascript-stringify","commit_stats":{"total_commits":79,"total_committers":11,"mean_commits":7.181818181818182,"dds":"0.26582278481012656","last_synced_commit":"2fc3aec529d8d6e062fc6d20d5f6d04047f67d24"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fjavascript-stringify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fjavascript-stringify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fjavascript-stringify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fjavascript-stringify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakeembrey","download_url":"https://codeload.github.com/blakeembrey/javascript-stringify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253441847,"owners_count":21909196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code","javascript","javascript-stringify","json","serialize","stringify"],"created_at":"2024-10-03T10:53:51.433Z","updated_at":"2025-05-16T06:07:55.335Z","avatar_url":"https://github.com/blakeembrey.png","language":"TypeScript","readme":"# JavaScript Stringify\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n[![Build status][build-image]][build-url]\n[![Build coverage][coverage-image]][coverage-url]\n\n\u003e Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`.\n\n## Installation\n\n```\nnpm install javascript-stringify --save\n```\n\n## Usage\n\n```javascript\nimport { stringify } from \"javascript-stringify\";\n```\n\nThe API is similar `JSON.stringify`:\n\n- `value` The value to convert to a string\n- `replacer` A function that alters the behavior of the stringification process\n- `space` A string or number that's used to insert white space into the output for readability purposes\n- `options`\n  - **maxDepth** _(number, default: 100)_ The maximum depth of values to stringify\n  - **maxValues** _(number, default: 100000)_ The maximum number of values to stringify\n  - **references** _(boolean, default: false)_ Restore circular/repeated references in the object (uses IIFE)\n  - **skipUndefinedProperties** _(boolean, default: false)_ Omits `undefined` properties instead of restoring as `undefined`\n\n### Examples\n\n```javascript\nstringify({}); // \"{}\"\nstringify(true); // \"true\"\nstringify(\"foo\"); // \"'foo'\"\n\nstringify({ x: 5, y: 6 }); // \"{x:5,y:6}\"\nstringify([1, 2, 3, \"string\"]); // \"[1,2,3,'string']\"\n\nstringify({ a: { b: { c: 1 } } }, null, null, { maxDepth: 2 }); // \"{a:{b:{}}}\"\n\n/**\n * Invalid key names are automatically stringified.\n */\nstringify({ \"some-key\": 10 }); // \"{'some-key':10}\"\n\n/**\n * Some object types and values can remain identical.\n */\nstringify([/.+/gi, new Number(10), new Date()]); // \"[/.+/gi,new Number(10),new Date(1406623295732)]\"\n\n/**\n * Unknown or circular references are removed.\n */\nvar obj = { x: 10 };\nobj.circular = obj;\n\nstringify(obj); // \"{x:10}\"\nstringify(obj, null, null, { references: true }); // \"(function(){var x={x:10};x.circular=x;return x;}())\"\n\n/**\n * Specify indentation - just like `JSON.stringify`.\n */\nstringify({ a: 2 }, null, \" \"); // \"{\\n a: 2\\n}\"\nstringify({ uno: 1, dos: 2 }, null, \"\\t\"); // \"{\\n\\tuno: 1,\\n\\tdos: 2\\n}\"\n\n/**\n * Add custom replacer behaviour - like double quoted strings.\n */\nstringify([\"test\", \"string\"], function (value, indent, stringify) {\n  if (typeof value === \"string\") {\n    return '\"' + value.replace(/\"/g, '\\\\\"') + '\"';\n  }\n\n  return stringify(value);\n});\n//=\u003e '[\"test\",\"string\"]'\n```\n\n## Formatting\n\nYou can use your own code formatter on the result of `javascript-stringify`. Here is an example using [eslint](https://www.npmjs.com/package/eslint):\n\n```javascript\nconst { CLIEngine } = require(\"eslint\");\nconst { stringify } = require(\"javascript-stringify\");\n\nconst { APP_ROOT_PATH, ESLINTRC_FILE_PATH } = require(\"./constants\");\n\nconst ESLINT_CLI = new CLIEngine({\n  fix: true,\n  cwd: APP_ROOT_PATH,\n  configFile: ESLINTRC_FILE_PATH,\n});\n\nmodule.exports = (objectToStringify) =\u003e {\n  return ESLINT_CLI.executeOnText(stringify(objectToStringify)).results[0]\n    .output;\n};\n```\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/javascript-stringify\n[npm-url]: https://npmjs.org/package/javascript-stringify\n[downloads-image]: https://img.shields.io/npm/dm/javascript-stringify\n[downloads-url]: https://npmjs.org/package/javascript-stringify\n[build-image]: https://img.shields.io/github/workflow/status/blakeembrey/javascript-stringify/CI/main\n[build-url]: https://github.com/blakeembrey/javascript-stringify/actions/workflows/ci.yml?query=branch%3Amain\n[coverage-image]: https://img.shields.io/codecov/c/gh/blakeembrey/javascript-stringify\n[coverage-url]: https://codecov.io/gh/blakeembrey/javascript-stringify\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Fjavascript-stringify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakeembrey%2Fjavascript-stringify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Fjavascript-stringify/lists"}