Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
module-definition
Advanced tools
Determines the module definition type (CommonJS, AMD, ES6, or none) for a given JavaScript file by walking through the AST.
npm install module-definition
var getModuleType = require('module-definition');
// Async
getModuleType('myscript.js', function (err, type) {
console.log(type);
});
// Sync
var type = getModuleType.sync('myscript.js');
console.log(type);
// From source (string or an AST)
var type = getModuleType.fromSource('define({foo: "foo"});');
console.log(type);
Passes one of the following strings to the given callback or returns the string in sync api:
amd
commonjs
es6
none
You may also pass an AST to fromSource
to avoid an internal parsing of the source
Via shell command (requires a global install: npm install -g module-definition
)
module-definition filename
FAQs
Determines if a file is using a CommonJS or AMD module definition
The npm package module-definition receives a total of 989,408 weekly downloads. As such, module-definition popularity was classified as popular.
We found that module-definition demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.