Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

detective-module

2.0.0 • Public • Published

detective-module npm npm

Get the dependencies specifier of an ES6 module

npm install detective-module

Usage

var detective = require('detective-module');
 
var mySourceCode = fs.readFileSync('myfile.js', 'utf8');
 
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
 
// input:
import Abc, * as BBBBBB from "mylib";
 
// output
[{
  "name": "mylib",
  "default": "Abc",
  "star": true,
  "alias": "BBBBBB"
}]
 

Example

// input:
import {foo as Foo, bar} from "mylib";
 
// output
[{
  "name": "mylib",
  "members": [{
    "name": "foo",
    "alias": "Foo"
  }, {
    "name": "bar",
    "alias": "bar"
  }]
}]
 

License

MIT

Install

npm i detective-module

DownloadsWeekly Downloads

11

Version

2.0.0

License

MIT

Last publish

Collaborators

  • avatar