Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

parse-import-specifiers

putoutjs15.3kMIT1.0.3

Simplest possible way to parse ImportSpecifiers

putout, AST, babel, import, specifier, import-specifier, parser

readme

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

changelog

2024.03.06, v1.0.3

fix:

  • 4f18e3f homepage

feature:

  • 6991ac2 parse-import-specifiers: c8 v9.1.0
  • b1f34e2 parse-import-specifiers: eslint-plugin-putout v22.4.0
  • 30cdb89 parse-import-specifiers: madrun v10.0.1
  • 1926c77 parse-import-specifiers: putout v35.6.0
  • 38b607c parse-import-specifiers: supertape v10.3.0
  • bfb6bd5 package: nodemon v3.0.1
  • 3da6518 package: eslint-plugin-putout v18.1.0
  • facbfad package: putout v30.3.0
  • d5c5264 package: c8 v8.0.0

2023.06.07, v1.0.2

feature:

  • 74011db package: keywrods

2023.06.07, v1.0.1

fix:

  • 8db5bed drop changelog