We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5f1623 commit 357c1e3Copy full SHA for 357c1e3
lib/serializer.js
@@ -1,5 +1,8 @@
1
'use strict'
2
3
+// eslint-disable-next-line
4
+const STR_ESCAPE = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/
5
+
6
module.exports = class Serializer {
7
constructor (options = {}) {
8
switch (options.rounding) {
@@ -94,6 +97,11 @@ module.exports = class Serializer {
94
97
str = str.toString()
95
98
}
96
99
100
+ // Fast escape chars check
101
+ if (!STR_ESCAPE.test(str)) {
102
+ return quotes + str + quotes
103
+ }
104
105
if (str.length < 42) {
106
return this.asStringSmall(str)
107
} else {
0 commit comments