Socket
Socket
Sign inDemoInstall

parse-es6-imports

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parse-es6-imports

Parse ES6 imports from a string


Version published
Weekly downloads
3.2K
increased by35.41%
Maintainers
1
Install size
8.27 kB
Created
Weekly downloads
 

Readme

Source

parse-es6-imports Build Status

Parse ES6 imports from a string

Install

$ npm install parse-es6-imports --save

Usage

const parseImports = require('parse-es6-imports')

const code = `
  import defaultA from './moduleA'
  import defaultB, { namedB } from './moduleB'
  import { namedC } from './moduleC'
  import { namedD as otherName } from './moduleD'
  import * as moduleE from './moduleE'
  import './moduleF'
`

const result = parseImports(code)

console.log(JSON.stringify(result, null, 2))

// [
//   {
//     "defaultImport": "defaultA",
//     "namedImports": [],
//     "starImport": null,
//     "fromModule": "./moduleA"
//   },
//   {
//     "defaultImport": "defaultB",
//     "namedImports": [
//       {
//         "name": "namedB",
//         "value": "namedB"
//       }
//     ],
//     "starImport": null,
//     "fromModule": "./moduleB"
//   },
//   {
//     "defaultImport": null,
//     "namedImports": [
//       {
//         "name": "namedC",
//         "value": "namedC"
//       }
//     ],
//     "starImport": null,
//     "fromModule": "./moduleC"
//   },
//   {
//     "defaultImport": null,
//     "namedImports": [
//       {
//         "name": "namedD",
//         "value": "otherName"
//       }
//     ],
//     "starImport": null,
//     "fromModule": "./moduleD"
//   },
//   {
//     "defaultImport": null,
//     "namedImports": [],
//     "starImport": "moduleE",
//     "fromModule": "./moduleE"
//   },
//   {
//     "defaultImport": null,
//     "namedImports": [],
//     "starImport": null,
//     "fromModule": "./moduleF"
//   }
// ]

License

MIT

Keywords

FAQs

Last updated on 13 Mar 2017

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