Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions lib/source-map-consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,14 +966,22 @@ BasicSourceMapConsumer.prototype.computeColumnSpans =
*/
BasicSourceMapConsumer.prototype.originalPositionFor =
function SourceMapConsumer_originalPositionFor(aArgs) {
var needleLine = util.getArg(aArgs, 'line');
var needleColumn = util.getArg(aArgs, 'column');
// The legacy code path went through `_findMapping` which validated
// line/column at the entry. Slab-direct lookups bypass that, so
// we have to validate explicitly to keep the documented errors.
// Inline the optional read for required args — every trace call paid
// for a `getArg` function call plus an `'in' in aArgs` check. Combining
// the value validation with a `typeof !== 'number'` guard preserves the
// documented "is a required argument" error for missing/undefined args
// while skipping the function-call overhead.
var needleLine = aArgs.line;
var needleColumn = aArgs.column;
if (typeof needleLine !== 'number') {
throw new Error('"line" is a required argument.');
}
if (needleLine <= 0) {
throw new TypeError('Line must be greater than or equal to 1, got ' + needleLine);
}
if (typeof needleColumn !== 'number') {
throw new Error('"column" is a required argument.');
}
if (needleColumn < 0) {
throw new TypeError('Column must be greater than or equal to 0, got ' + needleColumn);
}
Expand Down Expand Up @@ -1202,11 +1210,18 @@ BasicSourceMapConsumer.prototype.generatedPositionFor =
};
}

var needleLine = util.getArg(aArgs, 'line');
var needleColumn = util.getArg(aArgs, 'column');
// Inline the required-arg reads — same pattern as originalPositionFor.
var needleLine = aArgs.line;
var needleColumn = aArgs.column;
if (typeof needleLine !== 'number') {
throw new Error('"line" is a required argument.');
}
if (needleLine <= 0) {
throw new TypeError('Line must be greater than or equal to 1, got ' + needleLine);
}
if (typeof needleColumn !== 'number') {
throw new Error('"column" is a required argument.');
}
if (needleColumn < 0) {
throw new TypeError('Column must be greater than or equal to 0, got ' + needleColumn);
}
Expand Down
Loading