ast-module-types
Advanced tools
Comparing version 1.0.0 to 1.1.0
10
index.js
@@ -21,2 +21,10 @@ // Whether or not the node represents an AMD define() call | ||
// Whether or not the node represents a require at the top of the module | ||
// This occurs when the module is an initialization (driver) script | ||
module.exports.isTopLevelRequire = function (node) { | ||
// If there's a require, it's either the top-level or nested | ||
// at which it still has at least 3 parents | ||
return types.isRequire(node) && node.parent.parent.parent.type === 'Program'; | ||
}; | ||
// Whether or not the node represents the use of | ||
@@ -62,2 +70,2 @@ // assigning something to module.exports or exports | ||
return args && args[0].type === 'ObjectExpression'; | ||
}; | ||
}; |
{ | ||
"name": "ast-module-types", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,3 @@ Collection of useful helper functions when trying to determine | ||
* `isRequire`: if node matches a `require` function all (declaring a dependency) | ||
* `isTopLevelRequire`: if node matches a `require` at the top of the file. App initialization (aka driver) scripts have this. | ||
* `isExports`: if the node matches CommonJS `module.exports` or `exports` (defining a module) | ||
@@ -17,0 +18,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4194
56
35