{"_id":"fast-stringify@4.0.3","bugs":{"url":"https://github.com/planttheidea/fast-stringify/issues"},"dist":{"shasum":"9926d334aa5538c8e8a3413cfdeb71b24f435af8","tarball":"http://registry-npm.ywwl.com/fast-stringify/download/fast-stringify-4.0.3.tgz","fileCount":13,"integrity":"sha512-HJouFZmaXofRDp0W/5998CAti608tPWj/twaY3DfvtnRqb4CU8X7HXSsuAxknWLyymnARNeNUz2xeY6+/DINZQ==","signatures":[{"sig":"MEUCIGxQ4oIIZkROEb33fzvU0qczoybv8OaueUcCw4VOuDRCAiEAyGFt/uG2z34fcw7jcGEqNfRwOws1sQBZjIljOGE5XOo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD9/YVL2QKD/fBDK1D/iJzXkETicugZ2Tfd0sWCNZRiNwIhAKnrmd1pdtrwoVdjpr07iyjK6lh/6CwQ/z0lgMQ3IpUX"}],"unpackedSize":78082,"size":10947,"noattachment":false,"key":"/fast-stringify/-/fast-stringify-4.0.3.tgz"},"main":"./dist/cjs/index.cjs","name":"fast-stringify","type":"module","types":"./index.d.ts","author":{"url":"https://www.planttheidea.com/","name":"Tony Quetano","email":"tony.quetano@planttheidea.com"},"module":"./dist/es/index.mjs","browser":"./dist/umd/index.js","exports":{".":{"import":{"types":"./dist/es/index.d.mts","default":"./dist/es/index.mjs"},"default":{"types":"./dist/umd/index.d.ts","default":"./dist/umd/index.js"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}}},"gitHead":"b9607c91903669757a21de49888d9441ef51cd6f","license":"MIT","scripts":{"dev":"vite --config=config/vite.config.ts","dist":"npm run clean && npm run build","lint":"eslint --max-warnings=0","test":"vitest run --config=config/vitest.config.ts","build":"npm run clean && npm run build:dist","clean":"rm -rf dist","start":"npm run dev","format":"prettier . --log-level=warn --write","clean:es":"rm -rf dist/es","lint:fix":"npm run lint -- --fix","benchmark":"npm run build && node benchmark/index.js","clean:cjs":"rm -rf dist/cjs","clean:min":"rm -rf dist/min","clean:umd":"rm -rf dist/umd","typecheck":"tsc --noEmit","build:dist":"NODE_ENV=production rollup -c config/rollup.config.js","release:rc":"release-it --config=config/release-it/rc.json","build:types":"pti fix-types -l dist","format:check":"prettier . --log-level=warn --check","release:beta":"release-it --config=config/release-it/beta.json","release:alpha":"release-it --config=config/release-it/alpha.json","release:stable":"release-it --config=config/release-it/stable.json","release:scripts":"npm run format:check && npm run typecheck && npm run lint && npm run test && npm run build"},"version":"4.0.3","_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"homepage":"https://github.com/planttheidea/fast-stringify#readme","keywords":["stringify","fast","serialize","json"],"repository":{"url":"git+https://github.com/planttheidea/fast-stringify.git","type":"git"},"_npmVersion":"11.12.1","description":"A blazing fast stringifier that safely handles circular objects","directories":{},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"sideEffects":false,"_nodeVersion":"24.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.1.3","react":"^19.2.7","eslint":"^9.39.4","lodash":"^4.18.1","rollup":"^4.62.2","vitest":"^4.1.10","prettier":"^3.9.4","react-dom":"^19.2.7","superjson":"^2.2.6","tinybench":"^6.0.2","json-cycle":"^1.5.0","release-it":"^20.2.1","typescript":"^5.9.3","@types/node":"^24.13.3","@types/react":"^19.2.17","@types/lodash":"^4.17.24","decircularize":"^1.0.0","eslint-loader":"^4.0.2","typescript-eslint":"^8.63.0","@vitest/coverage-v8":"^4.1.10","json-stringify-safe":"^5.0.1","json-stable-stringify":"^1.3.0","faster-stable-stringify":"^1.0.0","@planttheidea/build-tools":"^2.0.2","@typescript-eslint/parser":"^8.63.0","eslint-friendly-formatter":"^4.0.1","@types/json-stringify-safe":"^5.0.3","fast-json-stable-stringify":"^2.1.0","@typescript-eslint/eslint-plugin":"^8.63.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fast-stringify_4.0.3_1791965994698_0.6579514879344885"},"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":1791965994787,"_cnpm_publish_time":1791965994787,"dist-tags":{"latest":"4.0.3","next":"4.0.0-beta.0"}}