{"name":"fast-stringify","version":"4.0.0","keywords":["stringify","fast","serialize","json"],"author":{"name":"tony_quetano@planttheidea.com"},"license":"MIT","_id":"fast-stringify@4.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":"bc0365981be6a2c19086b5208399f63f8dedbb16","tarball":"http://registry-npm.ywwl.com/fast-stringify/download/fast-stringify-4.0.0.tgz","fileCount":16,"integrity":"sha512-lE2DIivBaLysf6hK5WH/VfMgqRbvBVHcpGVVTmA5Zi8oWIjq9YxIt6lYGdUgP1HNSXxTIat7HEIDnrSvXSeKQw==","signatures":[{"sig":"MEUCIHc364BH3+yb+MEfiNBQBamp5UH5S+fDZ5bwnTV85K2HAiEAurIQyW+TKDFHKQjRTArT1ANx7PdWE0/WI+0WzDRf5ug=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51586,"size":9110,"noattachment":false,"key":"/fast-stringify/-/fast-stringify-4.0.0.tgz"},"main":"dist/cjs/index.cjs","type":"module","types":"index.d.ts","module":"dist/esm/index.mjs","browser":"dist/umd/index.js","exports":{".":{"import":{"types":"./dist/esm/types/index.d.mts","default":"./dist/esm/index.mjs"},"default":{"types":"./dist/umd/types/index.d.ts","default":"./dist/umd/index.js"},"require":{"types":"./dist/cjs/types/index.d.cts","default":"./dist/cjs/index.cjs"}}},"gitHead":"b8932cc490ec475aa25c50b8c92cddf2527624df","scripts":{"dev":"vite --config config/vite.config.js","dist":"npm run clean && npm run build","lint":"eslint --max-warnings 0","test":"vitest run","build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:min","clean":"rm -rf dist","start":"npm run dev","release":"release-it","lint:fix":"npm run lint -- --fix","benchmark":"npm run clean:esm && npm run build:esm && node benchmark/index.js","build:cjs":"NODE_ENV=production rollup -c config/rollup/config.cjs.js && tsc -p config/tsconfig/cjs.json && node scripts/create-cts-files.js","build:esm":"NODE_ENV=production rollup -c config/rollup/config.esm.js && tsc -p config/tsconfig/esm.json && node scripts/create-mts-files.js","build:min":"NODE_ENV=production rollup -c config/rollup/config.min.js && tsc -p config/tsconfig/min.json","build:umd":"NODE_ENV=production rollup -c config/rollup/config.umd.js && tsc -p config/tsconfig/umd.json","clean:cjs":"rm -rf dist/cjs","clean:esm":"rm -rf dist/esm","clean:min":"rm -rf dist/min","clean:umd":"rm -rf dist/umd","typecheck":"tsc --noEmit","test:watch":"vitest","release:beta":"release-it --config=.release-it.beta.json","test:coverage":"vitest run --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":"11.6.2","description":"A blazing fast stringifier that safely handles circular objects","directories":{},"_nodeVersion":"24.8.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.2.2","react":"^19.2.0","eslint":"^9.39.1","lodash":"^4.17.21","rollup":"^4.53.2","vitest":"^4.0.8","prettier":"^3.6.2","react-dom":"^19.2.0","superjson":"^2.2.5","tinybench":"^5.1.0","json-cycle":"^1.5.0","release-it":"^19.0.6","typescript":"^5.9.3","@types/node":"^24.10.0","@types/react":"^19.2.2","@types/lodash":"^4.17.20","decircularize":"^1.0.0","eslint-loader":"^4.0.2","typescript-eslint":"^8.46.4","@vitest/coverage-v8":"^4.0.8","json-stringify-safe":"^5.0.1","@rollup/plugin-terser":"^0.4.4","json-stable-stringify":"^1.3.0","@rollup/plugin-commonjs":"^29.0.0","faster-stable-stringify":"^1.0.0","@rollup/plugin-typescript":"^12.3.0","@typescript-eslint/parser":"^8.46.4","eslint-friendly-formatter":"^4.0.1","@types/json-stringify-safe":"^5.0.3","fast-json-stable-stringify":"^2.1.0","@rollup/plugin-node-resolve":"^16.0.3","@typescript-eslint/eslint-plugin":"^8.46.4"},"_npmOperationalInternal":{"tmp":"tmp/fast-stringify_4.0.0_1762898307335_0.818323721724848","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":1762898307543,"_cnpm_publish_time":1762898307543,"dist-tags":{"latest":"4.0.3","next":"4.0.0-beta.0"}}