Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function findOriginalPos(
frame: StackFrameInput,
module: ExplodedSourceMapModule,
): ?Position {
if (
module.map == null ||
frame.lineNumber == null ||
frame.column == null
) {
return null;
}
const generatedPosInModule = {
line1Based: frame.lineNumber - module.firstLine1Based + 1,
column0Based: frame.column,
};
const mappingIndex = greatestLowerBound(
module.map,
generatedPosInModule,
(target, candidate) => {
if (target.line1Based === candidate[0]) {
return target.column0Based - candidate[1];
}
return target.line1Based - candidate[0];
},
);
if (mappingIndex == null) {
return null;
}
const mapping = module.map[mappingIndex];
if (
mapping[0] !== generatedPosInModule.line1Based ||
mapping.length < 4 /* no source line/column info */
function findModule(frame: StackFrameInput): ?ExplodedSourceMapModule {
const map = mapsByUrl.get(frame.file);
if (!map || frame.lineNumber == null) {
return null;
}
const moduleIndex = greatestLowerBound(
map,
frame.lineNumber,
(target, candidate) => target - candidate.firstLine1Based,
);
if (moduleIndex == null) {
return null;
}
return map[moduleIndex];
}