You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New Js Example: Top level await implementation for modern Browsers #337
✅ Tested on PDF generation HTML template with Puppeteer, run in NodeJS application.
<head><!-- ...other files and HTML tags... --><!-- Load the RDKit JS file --><scriptsrc="https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.js"></script><!-- Instantiate the WASM module. The inline script below could live elsewhere inside your application code. --><scripttype="module">constRDKitModule=awaitinitRDKitModule();// <-- Top level awaitconstsmiles="CC(=O)Oc1ccccc1C(=O)O";constmol=RDKitModule.get_mol(smiles);constsvg=mol.get_svg();console.log(svg);</script><!-- ...your application code goes here... --></head>
Conclusion
After all, I got the proposed js example working. I just moved all my javascript code inside the .then statement.
Yeap, it works, but looks very messy and decreases readability.
Since most of the users are running modern browsers and my team works only with >=ES6, I really wanted that juicy syntactic sugar 🍭
Activity
MichelML commentedon Sep 19, 2023
@filoscoder this is great, definitely we should add examples with async/await soon
filoscoder commentedon Sep 19, 2023
That's good to know, hope this example helps future users :)