Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

module-definition

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-definition - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

test/a.js

57

index.js

@@ -20,2 +20,55 @@ var Walker = require('node-source-walk'),

// Whether or not the node represents a require function call
function isRequire(node) {
var c = node.callee;
return c &&
node.type === 'CallExpression' &&
c.type === 'Identifier' &&
c.name === 'require';
}
function isCommonJS(node) {
return isExports(node) ||
// there's a require with no define
(hasRequire(node) && ! hasDefine(node));
}
// Whether or not the node has a require call
// somewhere in its ast
function hasRequire(node) {
var sawRequire = false;
var walker = new Walker();
walker.traverse(node, function (node) {
if (isRequire(node)) {
sawRequire = true;
walker.stopWalking();
}
});
return sawRequire;
}
// Whether or not the node has a define call
// somewhere in its ast
function hasDefine(node) {
var sawDefine = false;
var walker = new Walker();
walker.traverse(node, function (node) {
if (isDefine(node)) {
sawDefine = true;
walker.stopWalking();
}
});
return sawDefine;
}
function isAMD(node) {
return isDefine(node);
}
module.exports = function (file, cb) {

@@ -38,7 +91,7 @@ if (! file) throw new Error('filename missing');

walker.walk(src, function (node) {
if (isExports(node)) {
if (isCommonJS(node)) {
type = 'commonjs';
walker.stopWalking();
} else if (isDefine(node)) {
} else if (isAMD(node)) {
type = 'amd';

@@ -45,0 +98,0 @@ walker.stopWalking();

4

package.json
{
"name": "module-definition",
"version": "1.0.2",
"version": "1.0.3",
"description": "Determines if a file is using a CommonJS or AMD module definition",

@@ -17,4 +17,4 @@ "main": "index.js",

"dependencies": {
"node-source-walk": "^1.0.0"
"node-source-walk": "^1.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc