Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return JSON.parse(string, reviver);
} catch (error) {
fallback(string, reviver);
throw error;
}
} catch (error) {
error.message = error.message.replace(/\n/g, '');
const indexMatch = error.message.match(/in JSON at position (\d+) while parsing near/);
const jsonError = new JSONError(error);
if (filename) {
jsonError.fileName = filename;
}
if (indexMatch && indexMatch.length > 0) {
const lines = new LinesAndColumns(string);
const index = Number(indexMatch[1]);
const location = lines.locationForIndex(index);
const codeFrame = codeFrameColumns(
string,
{start: {line: location.line + 1, column: location.column + 1}},
{highlightCode: true}
);
jsonError.codeFrame = codeFrame;
}
throw jsonError;
}
};
if (char === '\t' || char === '\n') {
continue;
}
const codePoint = char.codePointAt(0);
const isMissing = !characterSet.includes(codePoint);
if (isMissing) {
let location;
const charIdx = htmlAsset.text.indexOf(char);
if (charIdx === -1) {
location = `${htmlAsset.urlOrDescription} (generated content)`;
} else {
const position = new LinesAndColumns(
htmlAsset.text
).locationForIndex(charIdx);
location = `${htmlAsset.urlOrDescription}:${position.line +
1}:${position.column + 1}`;
}
missingGlyphsErrors.push({
codePoint,
char,
htmlAsset,
fontUsage,
location
});
}
}
}
if (char === '\t' || char === '\n') {
continue;
}
const codePoint = char.codePointAt(0);
const isMissing = !characterSet.includes(codePoint);
if (isMissing) {
let location;
const charIdx = htmlAsset.text.indexOf(char);
if (charIdx === -1) {
location = `${htmlAsset.urlOrDescription} (generated content)`;
} else {
const position = new LinesAndColumns(
htmlAsset.text
).locationForIndex(charIdx);
location = `${htmlAsset.urlOrDescription}:${position.line +
1}:${position.column + 1}`;
}
missingGlyphsErrors.push({
codePoint,
char,
htmlAsset,
fontUsage,
location
});
}
}
}