-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
base.js
36 lines (29 loc) 路 839 Bytes
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// @flow
import type { Options } from "../options";
import { isES2015ReservedWord } from "../util/identifier";
import type State from "../tokenizer/state";
import type { PluginsMap } from "./index";
export default class BaseParser {
// Properties set by constructor in index.js
options: Options;
inModule: boolean;
plugins: PluginsMap;
filename: ?string;
sawUnambiguousESM: boolean = false;
// Initialized by Tokenizer
state: State;
isReservedWord(word: string): boolean {
if (word === "await") {
return this.inModule;
} else {
return isES2015ReservedWord(word);
}
}
hasPlugin(name: string): boolean {
return this.plugins.has(name);
}
getPluginOption(plugin: string, name: string) {
// $FlowIssue
if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];
}
}