Use fast-json-escape for string serialization
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised
Issue
@BridgeAR has a nice fast-json-escape package that allows you to escape string for JSON format. It's a better implementation than ours because it doesn't have a fallback to the standard JSON.stringify that we have here. However, we need to add some adjustments to support surrogate pairs escaping. @BridgeAR already has an implementation like we need this.
I created a PR a few months ago, but it's still awaiting a response.
@mcollina What is the correct solution in this case? Should we copy the code and put in a license? From the other point of view, the code I want to copy is not a fresh idea. It's a strict implementation of the JSON spec.
I just released v2.0.0 that supports surrogate pairs. While checking the code, I noticed that the JSON.stringify got much faster escaping strings by now than in Node.js versions <= 10. It is now better to use JSON.stringify directly for escaping values, in case that's needed for the string.
That you for releasing a new version and for the hint. I will check the default JSON.stringify performance for this case.