Skip to content

Commit 14de5f8

Browse files
committed
Address comments in code review
1 parent 1ea5ee3 commit 14de5f8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

dist/source-map.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,8 @@ const INTERNAL = Symbol("smcInternal");
14611461
class SourceMapConsumer {
14621462
constructor(aSourceMap, aSourceMapURL) {
14631463
// If the constructor was called by super(), just return Promise<this>.
1464-
// Yes, this is a hack to retain the pre-existing API.
1464+
// Yes, this is a hack to retain the pre-existing API of the base-class
1465+
// constructor also being an async factory function.
14651466
if (aSourceMap == INTERNAL) {
14661467
return Promise.resolve(this);
14671468
}
@@ -2686,11 +2687,10 @@ function _factory(aSourceMap, aSourceMapURL) {
26862687
sourceMap = util.parseSourceMapInput(aSourceMap);
26872688
}
26882689

2689-
return Promise.resolve().then(_ => {
2690-
return sourceMap.sections != null
2690+
const consumer = sourceMap.sections != null
26912691
? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
26922692
: new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
2693-
});
2693+
return Promise.resolve(consumer);
26942694
}
26952695

26962696
function _factoryBSM(aSourceMap, aSourceMapURL) {

lib/source-map-consumer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const INTERNAL = Symbol("smcInternal");
1717
class SourceMapConsumer {
1818
constructor(aSourceMap, aSourceMapURL) {
1919
// If the constructor was called by super(), just return Promise<this>.
20-
// Yes, this is a hack to retain the pre-existing API.
20+
// Yes, this is a hack to retain the pre-existing API of the base-class
21+
// constructor also being an async factory function.
2122
if (aSourceMap == INTERNAL) {
2223
return Promise.resolve(this);
2324
}
@@ -1242,11 +1243,10 @@ function _factory(aSourceMap, aSourceMapURL) {
12421243
sourceMap = util.parseSourceMapInput(aSourceMap);
12431244
}
12441245

1245-
return Promise.resolve().then(_ => {
1246-
return sourceMap.sections != null
1246+
const consumer = sourceMap.sections != null
12471247
? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
12481248
: new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
1249-
});
1249+
return Promise.resolve(consumer);
12501250
}
12511251

12521252
function _factoryBSM(aSourceMap, aSourceMapURL) {

0 commit comments

Comments
 (0)