1.0.3 • Published 2 years ago
parse-import-specifiers v1.0.3
parse-import-specifiers 
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
ImportDefaultSpecifiercan 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-specifiersAPI
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