epoberezkin / fast-json-stable-stringify

Deterministic JSON.stringify() - a faster version of @substack's json-stable-strigify without jsonify.
Other
286 stars 34 forks source link

Performance increase with different design #62

Open AllNamesRTaken opened 3 years ago

AllNamesRTaken commented 3 years ago

I changed the algorithm to use the fact that object keys come in the order of creation. Instead of concatinating strings I just sort the properties of objects and to JSON.stringify over the whole result. Also replaced Object.keys with Object.getOwnPropertyNames since it seems faster. All tests are green and performance is better and at times faster than fast-stable-stringify. Code is also smaller.

Is this of interest and should I make a pull request?

epoberezkin commented 3 years ago

Thank you- where is this change?

AllNamesRTaken commented 3 years ago

On my machine, unused. I can create a PR and let you know.