Skip to content

Commit 81edd34

Browse files
committed
[Refactor] avoid recreating lowbyte function every time.
1 parent 4e576e5 commit 81edd34

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ function isElement (x) {
204204
function inspectString (str) {
205205
var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
206206
return "'" + s + "'";
207-
208-
function lowbyte (c) {
209-
var n = c.charCodeAt(0);
210-
var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n];
211-
if (x) return '\\' + x;
212-
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
213-
}
207+
}
208+
209+
function lowbyte (c) {
210+
var n = c.charCodeAt(0);
211+
var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n];
212+
if (x) return '\\' + x;
213+
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
214214
}
215215

216216
function markBoxed (str) {

0 commit comments

Comments
 (0)