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

ast-query

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-query - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

Gruntfile.js

@@ -25,3 +25,2 @@ module.exports = function (grunt) {

grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-release');

@@ -28,0 +27,0 @@ grunt.registerTask('default', [ 'jshint', 'simplemocha' ]);

8

lib/nodes/Body.js

@@ -9,5 +9,7 @@ 'use strict';

* @param {Object} node
* @param {Object} esprimaOptions
*/
var Body = module.exports = function (node) {
var Body = module.exports = function (node, esprimaOptions) {
this.node = node;
this.esprimaOptions = esprimaOptions;
};

@@ -21,3 +23,3 @@

Body.prototype.append = function (code) {
var values = esprima.parse(code).body;
var values = esprima.parse(code, this.esprimaOptions).body;
Array.prototype.push.apply(this.node, values);

@@ -33,3 +35,3 @@ return this;

Body.prototype.prepend = function (code) {
var values = esprima.parse(code).body;
var values = esprima.parse(code, this.esprimaOptions).body;
var insertionIndex = 0;

@@ -36,0 +38,0 @@ var nodes = this.node;

@@ -30,7 +30,7 @@ 'use strict';

function Tree(source, escodegenOptions, esprimaOptions) {
this.esprimaOptionDefaults = _.merge({}, esprimaOptionDefaults, esprimaOptions);
this.esprimaOptionDefaults = _.extend({}, esprimaOptionDefaults, esprimaOptions);
this.tree = esprima.parse(source.toString(), this.esprimaOptionDefaults);
this.tree = escodegen.attachComments(this.tree, this.tree.comments, this.tree.tokens);
this.body = new Body(this.tree.body);
this.escodegenOptions = _.merge({}, escodegenOptionDefaults, escodegenOptions);
this.body = new Body(this.tree.body, this.esprimaOptionDefaults);
this.escodegenOptions = _.extend({}, escodegenOptionDefaults, escodegenOptions);
}

@@ -37,0 +37,0 @@

{
"name": "ast-query",
"version": "1.1.0",
"version": "1.1.1",
"description": "Declarative JavaScript AST modification façade",

@@ -23,3 +23,3 @@ "main": "lib/tree.js",

"esprima": "^2.0.0",
"lodash": "^3.2.0",
"lodash": "^4.6.1",
"traverse": "^0.6.6"

@@ -30,6 +30,5 @@ },

"grunt-cli": "^0.1.9",
"grunt-contrib-jshint": "^0.11.0",
"grunt-release": "^0.11.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-simple-mocha": "^0.4.0"
}
}

@@ -50,3 +50,3 @@ AST Query

- **escodegenOptions** (Object) _optional_ - [escodegen](https://github.com/Constellation/escodegen) option object
- **esprimaOptions** (Object) _optional_ - object[esprima](http://esprima.org/doc) option
- **esprimaOptions** (Object) _optional_ - [esprima](http://esprima.org/doc) option object

@@ -53,0 +53,0 @@ Returns an AST tree you can then query as explained below:

@@ -69,8 +69,9 @@ var assert = require('assert');

});
it('parses the source code as a module when the sourceType configuration is present', function () {
assert.doesNotThrow(function () {
program('var a = 1;\nexport default a;', {}, { sourceType: 'module'});
}, Error);
});
});
});
});
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