Skip to content

Commit 8474a98

Browse files
authored
refactor(json): simplify strict mode error string construction (#693)
1 parent 03f17c2 commit 8474a98

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Unreleased
2+
=========================
3+
* refactor(json): simplify strict mode error string construction
4+
15
2.2.1 / 2025-11-24
26
=========================
37

lib/types/json.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ function createStrictSyntaxError (str, char) {
102102
var partial = ''
103103

104104
if (index !== -1) {
105-
partial = str.substring(0, index) + JSON_SYNTAX_CHAR
106-
107-
for (var i = index + 1; i < str.length; i++) {
108-
partial += JSON_SYNTAX_CHAR
109-
}
105+
partial = str.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str.length - index)
110106
}
111107

112108
try {

0 commit comments

Comments
 (0)