Nancy's Preferred Machete

    detective-module
    TypeScript icon, indicating that this package has built-in type declarations

    3.1.2 • Public • Published

    detective-module npm npm

    Get the dependencies specifier of an ES6 module And Require()

    npm install detective-module

    Usage

    var {
      detectiveModuleAndRequire,
      detectiveModule,
    } = 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

    14

    Version

    3.1.2

    License

    MIT

    Unpacked Size

    27.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • noyobo