parse-import-specifiers

1.0.3 • Public • Published

parse-import-specifiers NPM version

Parse ImportSpecifiers to 3 arrays according to type.

Reasoning

There is 3 types of ImportSpecifiers:

import test from 'supertape';
import * as test from 'supertape';
import {stub} from 'supertape';

So:

  • ☝️ When you generate code you should remember that after code transformations ImportDefaultSpecifier can be at the placce of an array.
  • ☝️ When you check specifiers to destructure you should distinguish Import Specifiers from each other to determine what to do next.

Install

npm i parse-import-specifiers

API

const {parseImportSpecifiers} = require('parse-imports-specifiers');
const {
    defaults,
    namespaces,
    imports,
} = parseImportSpecifiers(specifiers);

for (const spec of defaults) {}

for (const spec of namespaces) {}

for (const spec of imports) {}

License

MIT

Package Sidebar

Install

npm i parse-import-specifiers

Weekly Downloads

3,178

Version

1.0.3

License

MIT

Unpacked Size

5.4 kB

Total Files

5

Last publish

Collaborators

  • coderaiser