get-amd-module-type

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

MIT 18 个版本
安装
npm install get-amd-module-type
yarn add get-amd-module-type
pnpm add get-amd-module-type
bun add get-amd-module-type
README

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

// ESM
import getType from 'get-amd-module-type';
// or CJS
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

版本列表
7.0.0 2026-05-19
6.0.2 2026-04-13
6.0.1 2025-02-01
6.0.0 2024-04-14
5.0.1 2023-05-11
5.0.0 2023-05-04
4.1.0 2023-03-19
4.0.0 2022-03-03
3.0.2 2022-02-26
3.0.1 2022-02-26
3.0.0 2018-09-03
2.0.5 2016-09-05
2.0.4 2016-06-16
2.0.3 2015-02-28
2.0.2 2014-11-08
2.0.1 2014-11-08
2.0.0 2014-11-01
1.0.0 2014-10-25