{"name":"fast-stringify","version":"3.0.0","keywords":["stringify","fast","serialize","json"],"author":{"name":"tony_quetano@planttheidea.com"},"license":"MIT","_id":"fast-stringify@3.0.0","maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"homepage":"https://github.com/planttheidea/fast-stringify#readme","bugs":{"url":"https://github.com/planttheidea/fast-stringify/issues"},"dist":{"shasum":"3dbc32500410beb1586e46c45294cdc1c1b87958","tarball":"http://registry-npm.ywwl.com/fast-stringify/download/fast-stringify-3.0.0.tgz","fileCount":13,"integrity":"sha512-jZh6AwlpZ+HX5lXJRlR1Ko4lSHDxdhvFAHEuSRik+s1pjkvRMzkEdeV5E5odTQwP/i2ddFPf9zUgJSMSA+QFlQ==","signatures":[{"sig":"MEQCIDFaqWMjz+9qUwmVvy9C6+g46qxR7ue3u1sD2yDK4m0wAiBcGlQCLfz++E0ccMd5SEQ/RjBSRCpsit6iFayGK1oZMA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50325,"size":9501,"noattachment":false,"key":"/fast-stringify/-/fast-stringify-3.0.0.tgz"},"main":"dist/index.cjs.js","types":"index.d.ts","module":"dist/index.esm.js","browser":"dist/index.js","gitHead":"cdee72303096630eb66fcae705a328b8d2f7eb4a","scripts":{"dev":"NODE_ENV=development webpack-dev-server --progress --config=webpack/webpack.config.dev.js","dist":"npm run clean && npm run build && npm run copy:mjs","lint":"ESLINT_USE_FLAT_CONFIG=false eslint src/*.ts --max-warnings 0","test":"NODE_PATH=. BABEL_ENV=test jest","build":"NODE_ENV=production rollup -c","clean":"npm run clean:dist && npm run clean:mjs","start":"npm run dev","release":"release-it","copy:mjs":"node ./es-to-mjs.js","lint:fix":"ESLINT_USE_FLAT_CONFIG=false npm run lint -- --fix","benchmark":"npm run build && node benchmark/index.js","clean:mjs":"rm -rf mjs","typecheck":"tsc --noEmit","clean:dist":"rm -rf dist","test:watch":"npm test -- --watch","release:beta":"release-it --config=.release-it.beta.json","test:coverage":"npm test -- --coverage","release:scripts":"npm run typecheck && npm run lint && npm run test:coverage && npm run dist"},"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"repository":{"url":"git+https://github.com/planttheidea/fast-stringify.git","type":"git"},"_npmVersion":"10.9.3","description":"A blazing fast stringifier that safely handles circular objects","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^30.1.3","react":"^19.1.1","eslint":"^9.36.0","lodash":"^4.17.21","rollup":"^4.52.2","ts-jest":"^29.4.4","webpack":"^5.101.3","react-dom":"^19.1.1","superjson":"^2.2.2","tinybench":"^5.0.1","@babel/cli":"^7.28.3","json-cycle":"^1.5.0","release-it":"^19.0.5","typescript":"^5.9.2","@babel/core":"^7.28.4","@types/jest":"^30.0.0","webpack-cli":"^6.0.1","@types/react":"^19.1.13","babel-loader":"^10.0.0","@types/lodash":"^4","decircularize":"^1.0.0","eslint-loader":"^4.0.2","@babel/runtime":"^7.28.4","@babel/preset-env":"^7.28.3","webpack-dev-server":"^5.2.2","@babel/preset-react":"^7.27.1","babel-preset-minify":"^0.5.2","html-webpack-plugin":"^5.6.4","json-stringify-safe":"^5.0.1","rollup-plugin-babel":"^4.4.0","eslint-plugin-import":"^2.32.0","rollup-plugin-terser":"^7.0.2","eslint-webpack-plugin":"^4.2.0","json-stable-stringify":"^1.3.0","@babel/preset-typescript":"^7.27.1","@typescript-eslint/parser":"^8.44.1","eslint-friendly-formatter":"^4.0.1","@types/json-stringify-safe":"^5.0.3","fast-json-stable-stringify":"^2.1.0","@babel/plugin-transform-runtime":"^7.28.3","@typescript-eslint/eslint-plugin":"^8.44.1","@babel/plugin-proposal-json-strings":"^7.18.6","@babel/plugin-proposal-class-properties":"^7.18.6"},"_npmOperationalInternal":{"tmp":"tmp/fast-stringify_3.0.0_1758882003022_0.826925459893272","host":"s3://npm-registry-packages-npm-production"},"readme":"# fast-stringify\n\nA tiny, [blazing fast](#benchmarks) stringifier that safely handles circular objects.\n\nThe fastest way to stringify an object will always be the native `JSON.stringify`, but it does not support circular\nobjects out of the box. If you need to stringify objects that have circular references, `fast-stringify` is there for\nyou! It has a simple API to allow for several use-cases that `JSON.stringify` does not while also maintaining blazing\nfast performance compared to its peers.\n\n## Table of contents\n\n- [fast-stringify](#fast-stringify)\n  - [Table of contents](#table-of-contents)\n  - [Usage](#usage)\n    - [stringify](#stringify)\n  - [Importing](#importing)\n  - [Benchmarks](#benchmarks)\n    - [Simple objects](#simple-objects)\n    - [Complex objects](#complex-objects)\n    - [Circular objects](#circular-objects)\n    - [Special objects](#special-objects)\n    - [Stable objects](#stable-objects)\n    - [Stable circular objects](#stable-circular-objects)\n\n## Usage\n\n```javascript\nimport { stringify } from 'fast-stringify';\n\nconst object = {\n  foo: 'bar',\n  deeply: {\n    recursive: {\n      object: {},\n    },\n  },\n};\n\nobject.deeply.recursive.object = object.deeply.recursive;\n\nconsole.log(stringify(object));\n// {\"foo\":\"bar\",\"deeply\":{\"recursive\":{\"object\":\"[ref=.deeply.recursive]\"}}}\n```\n\n### stringify\n\n```ts\ninterface Options {\n  circularReplacer?: (key: string, value: any, referenceKey: string) => any;\n  indent?: number | string;\n  replacer?: (key: string, value: any) => any;\n  stable?: boolean;\n  stabilizer?: (\n    entryA: { key: string; value: any },\n    entryB: { key: string; value: any },\n    stabilizerOptions: { get: (key: string) => any },\n  ) => any;\n}\n\nfunction stringify(value: undefined | symbol | ((...args: any[]) => any), options?: Options): undefined;\nfunction stringify<Value>(value: Value, options?: Options): string;\n```\n\nStringifies the object passed based on the options passed. The only required value is the `value`. The additional optons\npassed will customize how the string is compiled. Available options:\n\n- `replacer` => function to customize how the non-circular value is stringified (see\n  [the documentation for JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)\n  for more details)\n- `indent` => white space used to indent the stringified object for pretty-printing, either as a number of spaces or as\n  the literal string to indent with (see\n  [the documentation for JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)\n  for more details)\n- `circularReplacer` => function to customize how the circular value is stringified (defaults to `[ref=##]` where `##`\n  is the `referenceKey`)\n  - `referenceKey` is a dot-separated key list reflecting the nested key the object was originally declared at\n  - keys that would be ambiguous left bare, because they are empty or contain a `.`, `\"`, or `\\`, are quoted as JSON\n    strings, so the path always identifies exactly one value:\n\n    ```javascript\n    stringify(nested); // {\"x\":{\"y\":{\"z\":{\"back\":\"[ref=.x.y]\"}}}}\n    stringify(dotted); // {\"x.y\":{\"z\":{\"back\":\"[ref=.\\\"x.y\\\"]\"}}}\n    ```\n- `stable` => whether to sort the keys for stability\n  - keys are sorted in ascending order by UTF-16 code unit, matching the default `Array.prototype.sort` ordering.\n    Locale-aware comparison is deliberately not used, because it would make output vary between environments.\n- `stabilizer` => function to customize how the stable object is sorted (only applies when `stable` is `true`)\n\n`stringify` returns `undefined` rather than a string when `value` itself is not serializable, which is the case for\n`undefined`, functions, and symbols. Non-serializable values _nested_ within `value` always produce a string: keys on\nobjects are omitted, and entries in arrays become `null`.\n\n## Importing\n\n```javascript\n// ESM\nimport { stringify } from 'fast-stringify';\n\n// CommonJS\nconst { stringify } = require('fast-stringify');\n```\n\n## Benchmarks\n\n### Simple objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ fast-stringify             │ 1385041 │ '± 0.01%'       │\n│ faster-stable-stringify    │ 1036269 │ '± 0.02%'       │\n│ fast-json-stable-stringify │ 1025641 │ '± 0.02%'       │\n│ json-stringify-safe        │ 840336  │ '± 0.02%'       │\n│ json-stable-stringify      │ 713266  │ '± 0.02%'       │\n│ decircularize              │ 468823  │ '± 0.03%'       │\n│ superjson                  │ 272034  │ '± 0.03%'       │\n│ json-cycle                 │ 6976    │ '± 0.09%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"fast-stringify\".\n```\n\n### Complex objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ fast-stringify             │ 227583  │ '± 0.05%'       │\n│ fast-json-stable-stringify │ 193535  │ '± 0.05%'       │\n│ faster-stable-stringify    │ 176553  │ '± 0.06%'       │\n│ json-stringify-safe        │ 142146  │ '± 0.07%'       │\n│ json-stable-stringify      │ 112246  │ '± 0.08%'       │\n│ decircularize              │ 61656   │ '± 0.10%'       │\n│ superjson                  │ 42057   │ '± 0.11%'       │\n│ json-cycle                 │ 1038    │ '± 0.62%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"fast-stringify\".\n```\n\n### Circular objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ fast-stringify             │ 174703  │ '± 0.04%'       │\n│ fast-json-stable-stringify │ 151906  │ '± 0.07%'       │\n│ faster-stable-stringify    │ 143843  │ '± 0.07%'       │\n│ json-stringify-safe        │ 105218  │ '± 0.11%'       │\n│ json-stable-stringify      │ 87382   │ '± 0.07%'       │\n│ decircularize              │ 52408   │ '± 0.10%'       │\n│ superjson                  │ 30303   │ '± 0.13%'       │\n│ json-cycle                 │ 972     │ '± 0.20%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"fast-stringify\".\n```\n\n### Special objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ fast-stringify             │ 81506   │ '± 0.05%'       │\n│ json-stringify-safe        │ 54552   │ '± 0.09%'       │\n│ fast-json-stable-stringify │ 51421   │ '± 0.10%'       │\n│ faster-stable-stringify    │ 47982   │ '± 0.10%'       │\n│ json-stable-stringify      │ 34450   │ '± 0.11%'       │\n│ decircularize              │ 20153   │ '± 0.13%'       │\n│ superjson                  │ 14992   │ '± 0.16%'       │\n│ json-cycle                 │ 384     │ '± 0.11%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"fast-stringify\".\n```\n\n### Stable objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ fast-json-stable-stringify │ 699300  │ '± 0.03%'       │\n│ faster-stable-stringify    │ 679347  │ '± 0.04%'       │\n│ fast-stringify             │ 580383  │ '± 0.03%'       │\n│ json-stable-stringify      │ 415454  │ '± 0.04%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"fast-json-stable-stringify\".\n```\n\n### Stable circular objects\n\n```bash\n┌────────────────────────────┬─────────┬─────────────────┐\n│ (index)                    │ Ops/sec │ Margin of error │\n├────────────────────────────┼─────────┼─────────────────┤\n│ faster-stable-stringify    │ 440722  │ '± 0.04%'       │\n│ fast-json-stable-stringify │ 430848  │ '± 0.04%'       │\n│ fast-stringify             │ 358166  │ '± 0.04%'       │\n│ json-stable-stringify      │ 275938  │ '± 0.05%'       │\n└────────────────────────────┴─────────┴─────────────────┘\nFastest was \"faster-stable-stringify\".\n```\n","publish_time":1758882003197,"_cnpm_publish_time":1758882003197,"dist-tags":{"latest":"4.0.3","next":"4.0.0-beta.0"}}