From 068f7b1a0c24785de2b68b4e8b79f726a44b5b1b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 28 May 2019 12:59:00 -0700 Subject: [PATCH] Wasm: Throw an exception if Parser is constructed before init() resolves --- lib/binding_web/binding.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/binding_web/binding.js b/lib/binding_web/binding.js index 5aa116fa..027a0b89 100644 --- a/lib/binding_web/binding.js +++ b/lib/binding_web/binding.js @@ -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');