Skip to content

Commit 7f48cb6

Browse files
authored
refactor: use built-in wellformed operation (#774)
1 parent ad325d8 commit 7f48cb6

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/serializer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use strict'
22

3-
// eslint-disable-next-line
4-
const STR_ESCAPE = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/
5-
63
module.exports = class Serializer {
74
constructor (options) {
85
switch (options && options.rounding) {
@@ -117,7 +114,7 @@ module.exports = class Serializer {
117114
}
118115
}
119116
return (last === -1 && ('"' + str + '"')) || ('"' + result + str.slice(last) + '"')
120-
} else if (len < 5000 && STR_ESCAPE.test(str) === false) {
117+
} else if (len < 5000 && str.isWellFormed()) {
121118
// Only use the regular expression for shorter input. The overhead is otherwise too much.
122119
return '"' + str + '"'
123120
} else {

0 commit comments

Comments
 (0)