mix init options in the Module-global

This commit is contained in:
Johannes Rieken 2021-08-30 14:16:41 +02:00
parent 0926fad1e2
commit 12d727fd49
4 changed files with 48 additions and 29 deletions

View file

@ -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) => {