Skip to content

Commit

Permalink
perf: jump consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Oct 2, 2024
1 parent d076f1a commit eaff705
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"c8": "^10.1.2",
"grules": "^0.25.3",
"grules": "^0.25.5",
"tinybench": "^2.9.0",
"typescript": ">=5.6.2"
},
Expand Down
36 changes: 24 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,35 @@ const escapeFunction = (string) => {
const i = escapeRegExp.lastIndex - 1;

switch (string.charCodeAt(i)) {
case 34:
escaped += string.slice(start, i) + """; // "
// "
case 34: {
escaped += string.slice(start, i) + """;
break;
case 38:
escaped += string.slice(start, i) + "&"; // &
}
// &
case 38: {
escaped += string.slice(start, i) + "&";
break;
}
// '
case 39: {
escaped += string.slice(start, i) + "'";
break;
case 39:
escaped += string.slice(start, i) + "'"; // '
}
// <
case 60: {
escaped += string.slice(start, i) + "&#60;";
break;
case 60:
escaped += string.slice(start, i) + "&#60;"; // <
}
// =
case 61: {
escaped += string.slice(start, i) + "&#61;";
break;
case 61:
escaped += string.slice(start, i) + "&#61;"; // =
}
// >
case 62: {
escaped += string.slice(start, i) + "&#62;";
break;
default: {
escaped += string.slice(start, i) + "&#62;"; // >
}
}

Expand Down

0 comments on commit eaff705

Please sign in to comment.