UNPKG

nice-ui

Version:

React design system, components, and utilities

36 lines (35 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const loadScript = require('load-script'); // eslint-disable-line @typescript-eslint/no-var-requires // const URL = 'https://unpkg.com/charchem@0.0.2/easychem.js'; const URL = 'https://unpkg.com/charchem@0.0.2/charchem.js'; let promise = null; /** * This loads CharChem library from UNPKG. This function * is idempotent, you can call it any number of times. */ const loadCharChem = () => { if (!promise) { promise = (async () => { await new Promise((resolve, reject) => { loadScript(URL, (error, script) => { if (error) reject(error); else resolve(script); }); }); await new Promise((resolve) => { const wait = () => { if (window.ChemSys) resolve(); else setTimeout(wait, 25); }; wait(); }); })(); } return promise; }; exports.default = loadCharChem;