Test if object is es6 module

Viewed 118

Using dynamics imports like that:

const i = import('./path/to/module.js');

yields a Promise for that module. Assuming that ./path/to/module.js looks like that:

export function foo () {}
export function bar () {}
export default function () {}

the resulting object will have such a shape:

{
  foo: …
  bar: …
  default: …
}

Right now I need to figure out if a given Object is such a module, or any other one. So: Is there any test to determine if a given object is such a es6 module, obtained by a dynamic import?

0 Answers
Related