Right now when using $i it puts the result (when finished) on the global namespace - the window.
I'm proposing that instead it returns a promise (due to the async nature of import) that evaluates with the result of executing the desired imported module.
Something like this
$i('lodash').then(_ => _.toNumber(null));
This could also be used with top-level await like this
const _ = await $i('lodash');
_.toNumber(null);
This is gives you the control whether or not you want to pollute the global namespace and how.
Plus, now you don't have to know how the internal module exposes itself ($, _, etc.)
Right now when using
$i
it puts the result (when finished) on the global namespace - the window.I'm proposing that instead it returns a promise (due to the async nature of import) that evaluates with the result of executing the desired imported module.
Something like this
This could also be used with top-level await like this
This is gives you the control whether or not you want to pollute the global namespace and how. Plus, now you don't have to know how the internal module exposes itself (
$
,_
, etc.)