@kitschpatrol/safe-stable-stringify
v2.5.0-fork.2
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 BridgeAR/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.)
- Drop the CJS export.
- Incorporate all upstream commits since the August 2024 2.5.0 release.
- 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
Add it to your project:
npm install @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.01× | 1.02× | 1.00× | 1.01× | | Function replacer | 0.99× | 0.99× | 1.00× | 0.97× | | Array replacer | 0.99× | 1.00× | 0.98× | 0.99× | | Function replacer with indentation | 0.99× | 0.98× | 0.98× | 0.99× | | Array replacer with indentation | 1.00× | 1.00× | 1.00× | 0.98× | | Indentation | 1.01× | 0.99× | 0.97× | 0.99× |
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 | 0.99× |
| fast-safe-stringify | 1.13× |
| fast-stable-stringify | 0.92× |
| faster-stable-stringify | 1.03× |
| fastest-stable-stringify | 0.91× |
| json-stable-stringify | 1.31× |
| json-stringify-deterministic | 1.43× |
| safe-stable-stringify (upstream) | 1.00× |
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.
