* Create strict violation syntax error matching native error. * * @param {string} str * @param {string} char * @returns {Error} * @private
(str, char)
| 126 | * @private |
| 127 | */ |
| 128 | function createStrictSyntaxError (str, char) { |
| 129 | const index = str.indexOf(char) |
| 130 | let partial = '' |
| 131 | |
| 132 | if (index !== -1) { |
| 133 | partial = str.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str.length - index) |
| 134 | } |
| 135 | |
| 136 | try { |
| 137 | JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation') |
| 138 | } catch (e) { |
| 139 | return normalizeJsonSyntaxError(e, { |
| 140 | message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) { |
| 141 | return str.substring(index, index + placeholder.length) |
| 142 | }), |
| 143 | stack: e.stack |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Get the first non-whitespace character in a string. |
no test coverage detected
searching dependent graphs…