With the power of await, this isn't so difficult:

let nacl, scrypt;

function main() {
	/* Synchronous code that calls nacl and scrypt */
}

(async () => {
	[nacl, scrypt] = await Promise.all([new Promise(nacl_factory.instantiate), new Promise(scrypt_module_factory)]);
	return main();
})();

Leave a Reply

Your email address will not be published. Required fields are marked *