@kitschpatrol/safe-stable-stringify
v2.5.0-fork.1
Published
Fork of safe-stable-stringify with an ESM fix.
Maintainers
Readme
@kitschpatrol/safe-stable-stringify
Fork of safe-stable-stringify with an ESM fix.
Changes
This is a fork of safe-stable-stringify incorporating some minor fixes that I needed in other projects:
- Support direct-to-browser ESM imports. (Fixes an upstream issue from 2022.)
- Incorporate all upstream commits since the August 2024 2.5.0 release.
- The package now exports ESM only, no dual-package fuss.
- Port to TypeScript.
- Repository project template aligned with kitschpatrol/create-project. (Massive diff, but simplifies management on my end.)
It will be deprecated if / when fixes are available upstream.
Installation
To install:
pnpm add -D @kitschpatrol/safe-stable-stringifyPerformance
Performance tracks upstream.
As tested on an Apple M3 Max + Node.js 26:
Compared with upstream
Values show the throughput of @kitschpatrol/safe-stable-stringify vs. the upstream safe-stable-stringify. 1.00× means equal throughput; higher means this repo is faster.
| Task | Simple object | Circular | Deep | Deep circular | | :--------------------------------- | ------------: | -------: | ----: | ------------: | | Simple | 1.08× | 0.99× | 0.99× | 0.99× | | Function replacer | 1.06× | 0.99× | 0.99× | 1.01× | | Array replacer | 0.97× | 1.00× | 1.02× | 0.99× | | Function replacer with indentation | 1.01× | 0.98× | 1.00× | 0.98× | | Array replacer with indentation | 1.04× | 1.03× | 0.98× | 0.97× | | Indentation | 1.00× | 1.07× | 1.00× | 1.03× |
Compared with other implementations
Values show the throughput of @kitschpatrol/safe-stable-stringify relative to each named implementation. 1.00× means equal throughput; higher means this repo is faster.
| Compared with | Relative speed |
| :------------------------------------------------------------------------------------------ | -------------: |
| fast-json-stable-stringify | 1.06× |
| fast-safe-stringify | 1.17× |
| fast-stable-stringify | 0.94× |
| faster-stable-stringify | 1.06× |
| fastest-stable-stringify | 0.93× |
| json-stable-stringify | 1.32× |
| json-stringify-deterministic | 1.45× |
| safe-stable-stringify (upstream) | 1.05× |
Acknowledgments
The original implementation was created by Ruben Bridgewater.
The upstream project is sponsored by MaibornWolff and nearForm.
License
More information
Please see the upstream readme for more details and documentation.
