Skip to content

Commit 2c55e2f

Browse files
authored
refactor(json): simplify strict mode error string construction (#692)
1 parent 7db202c commit 2c55e2f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

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
1.20.4 / 2025-12-01
26
===================
37

lib/types/json.js

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

160160
if (index !== -1) {
161-
partial = str.substring(0, index) + JSON_SYNTAX_CHAR
162-
163-
for (var i = index + 1; i < str.length; i++) {
164-
partial += JSON_SYNTAX_CHAR
165-
}
161+
partial = str.substring(0, index) + new Array(str.length - index + 1).join(JSON_SYNTAX_CHAR)
166162
}
167163

168164
try {

0 commit comments

Comments
 (0)