@@ -9,27 +9,22 @@ const util = require("./util");
9
9
const binarySearch = require ( "./binary-search" ) ;
10
10
const ArraySet = require ( "./array-set" ) . ArraySet ;
11
11
const base64VLQ = require ( "./base64-vlq" ) ; // eslint-disable-line no-unused-vars
12
- const readWasm = require ( "../lib/read-wasm" ) ;
13
12
const wasm = require ( "./wasm" ) ;
14
13
15
14
const INTERNAL = Symbol ( "smcInternal" ) ;
16
15
17
16
class SourceMapConsumer {
18
17
constructor ( aSourceMap , aSourceMapURL ) {
19
- // If the constructor was called by super(), just return Promise< this> .
18
+ // If the constructor was called by super(), just return this.
20
19
// Yes, this is a hack to retain the pre-existing API of the base-class
21
- // constructor also being an async factory function.
20
+ // constructor also being an factory function.
22
21
if ( aSourceMap == INTERNAL ) {
23
- return Promise . resolve ( this ) ;
22
+ return this ;
24
23
}
25
24
26
25
return _factory ( aSourceMap , aSourceMapURL ) ;
27
26
}
28
27
29
- static initialize ( opts ) {
30
- readWasm . initialize ( opts [ "lib/mappings.wasm" ] ) ;
31
- }
32
-
33
28
static fromSourceMap ( aSourceMap , aSourceMapURL ) {
34
29
return _factoryBSM ( aSourceMap , aSourceMapURL ) ;
35
30
}
@@ -47,14 +42,14 @@ class SourceMapConsumer {
47
42
* the consumer, since it will be called automatically once `f` completes.
48
43
*
49
44
* ```js
50
- * const xSquared = await SourceMapConsumer.with(
45
+ * const xSquared = SourceMapConsumer.with(
51
46
* myRawSourceMap,
52
47
* null,
53
48
* async function (consumer) {
54
49
* // Use `consumer` inside here and don't worry about remembering
55
50
* // to call `destroy`.
56
51
*
57
- * const x = await whatever(consumer);
52
+ * const x = whatever(consumer);
58
53
* return x * x;
59
54
* }
60
55
* );
@@ -65,9 +60,9 @@ class SourceMapConsumer {
65
60
* ```
66
61
*/
67
62
static async with ( rawSourceMap , sourceMapUrl , f ) {
68
- const consumer = await new SourceMapConsumer ( rawSourceMap , sourceMapUrl ) ;
63
+ const consumer = new SourceMapConsumer ( rawSourceMap , sourceMapUrl ) ;
69
64
try {
70
- return await f ( consumer ) ;
65
+ return f ( consumer ) ;
71
66
} finally {
72
67
consumer . destroy ( ) ;
73
68
}
@@ -172,7 +167,8 @@ exports.SourceMapConsumer = SourceMapConsumer;
172
167
*/
173
168
class BasicSourceMapConsumer extends SourceMapConsumer {
174
169
constructor ( aSourceMap , aSourceMapURL ) {
175
- return super ( INTERNAL ) . then ( that => {
170
+ /* eslint-disable prettier/prettier */
171
+ const that = super ( INTERNAL ) ;
176
172
let sourceMap = aSourceMap ;
177
173
if ( typeof aSourceMap === "string" ) {
178
174
sourceMap = util . parseSourceMapInput ( aSourceMap ) ;
@@ -220,11 +216,12 @@ class BasicSourceMapConsumer extends SourceMapConsumer {
220
216
that . _mappingsPtr = 0 ;
221
217
that . _wasm = null ;
222
218
223
- return wasm ( ) . then ( w => {
224
- that . _wasm = w ;
219
+ // return wasm().then(w => {
220
+ that . _wasm = wasm ( ) ;
225
221
return that ;
226
- } ) ;
227
- } ) ;
222
+ // });
223
+ // });
224
+ /* eslint-enable/ prettier/prettier */
228
225
}
229
226
230
227
/**
@@ -721,7 +718,7 @@ exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
721
718
*/
722
719
class IndexedSourceMapConsumer extends SourceMapConsumer {
723
720
constructor ( aSourceMap , aSourceMapURL ) {
724
- return super ( INTERNAL ) . then ( that => {
721
+ const that = super ( INTERNAL ) ;
725
722
let sourceMap = aSourceMap ;
726
723
if ( typeof aSourceMap === "string" ) {
727
724
sourceMap = util . parseSourceMapInput ( aSourceMap ) ;
@@ -738,8 +735,8 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
738
735
line : - 1 ,
739
736
column : 0
740
737
} ;
741
- return Promise . all (
742
- sections . map ( s => {
738
+ // return Promise.all(
739
+ const mappedSecions = sections . map ( s => {
743
740
if ( s . url ) {
744
741
// The url field will require support for asynchronicity.
745
742
// See https://github.com/mozilla/source-map/issues/16
@@ -761,11 +758,11 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
761
758
}
762
759
lastOffset = offset ;
763
760
764
- const cons = new SourceMapConsumer (
761
+ const consumer = new SourceMapConsumer (
765
762
util . getArg ( s , "map" ) ,
766
763
aSourceMapURL
767
764
) ;
768
- return cons . then ( consumer => {
765
+ // return cons.then(consumer => {
769
766
return {
770
767
generatedOffset : {
771
768
// The offset fields are 0-based, but we use 1-based indices when
@@ -775,13 +772,13 @@ class IndexedSourceMapConsumer extends SourceMapConsumer {
775
772
} ,
776
773
consumer
777
774
} ;
778
- } ) ;
779
- } )
780
- ) . then ( s => {
781
- that . _sections = s ;
775
+ // });
776
+ } ) ;
777
+ // ).then(s => {
778
+ that . _sections = mappedSecions ;
782
779
return that ;
783
- } ) ;
784
- } ) ;
780
+ // });
781
+ // });
785
782
}
786
783
787
784
/**
@@ -1058,7 +1055,7 @@ function _factory(aSourceMap, aSourceMapURL) {
1058
1055
sourceMap . sections != null
1059
1056
? new IndexedSourceMapConsumer ( sourceMap , aSourceMapURL )
1060
1057
: new BasicSourceMapConsumer ( sourceMap , aSourceMapURL ) ;
1061
- return Promise . resolve ( consumer ) ;
1058
+ return consumer ;
1062
1059
}
1063
1060
1064
1061
function _factoryBSM ( aSourceMap , aSourceMapURL ) {
0 commit comments