Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
fast-stringify
Advanced tools
A blazing fast stringifier that safely handles circular objects
import stringify from "fast-stringify";
const object = {
foo: "bar",
deeply: {
recursive: {
object: {}
}
}
};
object.deeply.recursive.object = object;
console.log(stringify(object));
// {"foo":"bar","deeply":{"recursive":{"object":"[ref-0]"}}}
stringify(object: any, replacer: ?function, indent: ?number, circularReplacer: ?function): string
Stringifies the object passed based on the parameters you pass. The only required value is the object
. The additional parameters passed will customize how the string is compiled.
replacer
=> function to customize how the value for each key is stringified (see the documentation for JSON.stringify for more details)indent
=> number of spaces to indent the stringified object for pretty-printing (see the documentation for JSON.stringify for more details)circularReplacer
=> function to customize how the circular reference is stringified (defaults to [ref-##]
where ##
is the reference count)Small number of properties, all values are primitives
Operations / second | Relative margin of error | |
---|---|---|
fast-stringify | 633,749 | 0.85% |
fast-json-stable-stringify | 349,351 | 0.58% |
json-stringify-safe | 292,456 | 0.75% |
json-stable-stringify | 267,359 | 0.57% |
json-cycle | 193,863 | 0.71% |
decircularize | 121,932 | 0.70% |
Large number of properties, values are a combination of primitives and complex objects
Operations / second | Relative margin of error | |
---|---|---|
fast-stringify | 116,155 | 0.67% |
fast-json-stable-stringify | 57,484 | 0.68% |
json-cycle | 52,758 | 0.71% |
json-stringify-safe | 52,575 | 0.72% |
json-stable-stringify | 41,761 | 0.60% |
decircularize | 21,784 | 0.88% |
Objects that deeply reference themselves
Operations / second | Relative margin of error | |
---|---|---|
fast-stringify | 105,932 | 0.84% |
json-stringify-safe | 49,366 | 1.07% |
json-cycle | 49,152 | 0.67% |
decircularize | 20,626 | 0.81% |
fast-json-stable-stringify (not supported) | 0 | 0.00% |
json-stable-stringify (not supported) | 0 | 0.00% |
Custom constructors, React components, etc
Operations / second | Relative margin of error | |
---|---|---|
fast-stringify | 35,391 | 0.67% |
json-cycle | 20,413 | 0.63% |
fast-json-stable-stringify | 17,908 | 0.52% |
json-stringify-safe | 16,988 | 0.85% |
json-stable-stringify | 13,984 | 0.85% |
decircularize | 7,223 | 0.65% |
Standard practice, clone the repo and npm i
to get the dependencies. The following npm scripts are available:
rollup
clean:dist
, clean:es
, and clean:lib
scriptsrimraf
on the dist
folderrimraf
on the es
folderrimraf
on the lib
folderbuild
and build:minified
scriptssrc
folder (also runs on dev
script)lint
script, but with auto-fixerlint
, test:coverage
, transpile:lib
, transpile:es
, and dist
scriptsdev
test
foldertest
with code coverage calculation via nyc
test
but keep persistent watchersrc
folder (transpiled to es
folder without transpilation of ES2015 export syntax)src
folder (transpiled to lib
folder)1.0.1
FAQs
A blazing fast stringifier that safely handles circular objects
We found that fast-stringify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.