mix init options in the Module-global
This commit is contained in:
parent
0926fad1e2
commit
12d727fd49
4 changed files with 48 additions and 29 deletions
|
|
@ -1,9 +1,15 @@
|
|||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
window.TreeSitter = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
var TreeSitter = function() {
|
||||
var initPromise;
|
||||
class Parser {
|
||||
constructor() {
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
throw new Error("cannot construct a Parser before calling `init()`");
|
||||
}
|
||||
|
||||
static init(moduleOptions) {
|
||||
if (initPromise) return initPromise;
|
||||
Module = { ...Module, ...moduleOptions };
|
||||
return initPromise = new Promise((resolveInitPromise) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue