Socket
Socket
Sign inDemoInstall

ast-module-types

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-module-types - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

7

index.js

@@ -29,3 +29,3 @@ // Whether or not the node represents an AMD define() call

module.exports.isTopLevelRequire = function (node) {
if (!node.type === 'Program' || !node.body ||
if (node.type !== 'Program' || !node.body ||
!node.body.length || !node.body[0].expression) {

@@ -160,1 +160,6 @@ return false;

};
// import 'mylib' or import {foo, bar} from 'mylib'
module.exports.isES6Import = function(node) {
return node.type === 'ImportDeclaration' && node.source && node.source.value;
};

5

package.json
{
"name": "ast-module-types",
"version": "2.0.1",
"version": "2.1.0",
"description": "Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.",

@@ -28,5 +28,4 @@ "main": "index.js",

"devDependencies": {
"esprima": "~1.2.2",
"node-source-walk": "~1.1.2"
"node-source-walk": "~1.2.0"
}
}

@@ -27,2 +27,6 @@ Collection of useful helper functions when trying to determine

ES6 Types
* `isES6Import`: if the node is of the form: `import 'mylib'` or `import {something} from 'mylib'`
### Usage

@@ -33,3 +37,3 @@

// Assume node is some node of an AST that you parsed using esprima
// Assume node is some node of an AST that you parsed using esprima or esprima-fb
// ...

@@ -36,0 +40,0 @@

var types = require('../');
var esprima = require('esprima');
var assert = require('assert');

@@ -10,6 +9,7 @@ var util = require('util');

// a node in the AST of the given source code
function check(code, checker) {
var ast = esprima.parse(code);
function check(code, checker, harmony) {
var found = false;
var walker = new Walker();
var walker = new Walker({
esprimaHarmony: !!harmony
});

@@ -22,3 +22,3 @@ walker.walk(code, function(node) {

}
})
});

@@ -60,3 +60,3 @@ return found;

});
})
});

@@ -88,2 +88,8 @@ describe('AMD modules', function() {

});
describe('ES6', function() {
it('detects es6 imports', function() {
assert(check('import {foo, bar} from "mylib";\nimport "mylib2"', types.isES6Import, true));
});
});
});
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