Wasm: Throw an exception if Parser is constructed before init() resolves

This commit is contained in:
Max Brunsfeld 2019-05-28 12:59:00 -07:00
parent 621efeb543
commit 068f7b1a0c

View file

@ -27,6 +27,10 @@ class Parser {
}
constructor() {
if (TRANSFER_BUFFER == null) {
throw new Error('You must first call Parser.init() and wait for it to resolve.');
}
C._ts_parser_new_wasm();
this[0] = getValue(TRANSFER_BUFFER, 'i32');
this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');