get-amd-module-type

6.0.0 • Public • Published

get-amd-module-type

CI npm version npm downloads

Get the type of an AMD module used for an AST node or within a file

npm install get-amd-module-type

Usage

const getType = require('get-amd-module-type');

// Async
getType('my/file.js', (error, type) => {
  if (error) throw error;
  console.log(type);
});

let type;

// Sync
type = getType.sync('my/file.js');

// From source code
type = getType.fromSource('define() {}');

// From an AST node
type = getType.fromAST(node);

The returned type will be any of the following:

  • 'named': define('name', [deps], func)
  • 'deps': define([deps], func)
  • 'rem': define(function(require, exports, module){});
  • 'factory': define(function(require){})
  • 'nodeps': define({})
  • 'driver': require([deps], function)

License

MIT

Package Sidebar

Install

npm i get-amd-module-type

Weekly Downloads

1,217,006

Version

6.0.0

License

MIT

Unpacked Size

6.66 kB

Total Files

4

Last publish

Collaborators

  • pahen
  • xhmikosr
  • mrjoelkemp