parse-import-specifiers
Simplest possible way to parse ImportSpecifiers
Last updated 8 months ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install parse-import-specifiers 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.3                                ...           latest (8 months ago)

4 Versions

  • 1.0.3                                ...           8 months ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (12)

© 2010 - cnpmjs.org x YWFE | Home | YWFE