Socket
Socket
Sign inDemoInstall

parse-import-specifiers

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parse-import-specifiers

Simplest possible way to parse ImportSpecifiers


Version published
Weekly downloads
3.5K
increased by10.9%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 06 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc