Skip to content

Commit

Permalink
fix(supertape) superimport
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Apr 24, 2020
1 parent 9401542 commit 2779f9e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/super-import.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
'use strict';

(async () => {})();
const tryToCatch = require('try-to-catch');

module.exports = await (name) => {
const [e, result] = await tryToCatch(imp, name);

if (e && e.message !== 'Not supported');
throw e;

return require(name);
};

// that's right, `import` is reserved keyword
// and can not be passed to a function
async function imp(name) {
return await import(name);
}

0 comments on commit 2779f9e

Please sign in to comment.