Comparing version 0.1.0 to 0.1.1
var esquery = require("esquery") | ||
, escodegen = require("escodegen"); | ||
, recast = require("recast"); | ||
@@ -72,3 +72,13 @@ // AST data | ||
this.parentAttribute = parentAttribute; | ||
this.recastPrelude = null; | ||
if (ast.type === "File") { | ||
ast = ast.program; | ||
this.recastPrelude = { | ||
type: "File" | ||
, loc: ast.loc | ||
, comments: ast.comments | ||
}; | ||
} | ||
// copy ast information onto object | ||
@@ -127,3 +137,4 @@ forEachObject(ast, function (attr, value) { | ||
this._forEachAttribute(function (attr, value) { | ||
forEachObject(ATTR[this.type], function (attr) { | ||
var value = this[attr]; | ||
if (arrayInstanceOf(value, Element)) { | ||
@@ -136,3 +147,3 @@ children = children.concat(value); | ||
} | ||
}); | ||
}.bind(this)); | ||
@@ -333,2 +344,7 @@ return children; | ||
if (this.recastPrelude !== null && this.parentElement === null) { | ||
this.recastPrelude.program = element; | ||
return this.recastPrelude.program; | ||
} | ||
return element; | ||
@@ -338,3 +354,3 @@ }; | ||
Element.prototype.outerCode = function (opts) { | ||
return escodegen.generate(this.outerAST(), opts); | ||
return recast.print(this.outerAST(), opts).code; | ||
}; |
@@ -10,2 +10,10 @@ { | ||
}, | ||
"ArrayPattern": { | ||
"elements": [ | ||
[ | ||
"Pattern", | ||
"null" | ||
] | ||
] | ||
}, | ||
"ArrowExpression": { | ||
@@ -414,2 +422,10 @@ "body": [ | ||
}, | ||
"ObjectPattern": { | ||
"properties": [ | ||
[ | ||
null | ||
] | ||
] | ||
}, | ||
"Pattern": {}, | ||
"Position": { | ||
@@ -416,0 +432,0 @@ "column": [ |
@@ -5,4 +5,10 @@ { | ||
"Expression", | ||
"ArrayExpression" | ||
"ArrayExpression", | ||
"Pattern" | ||
], | ||
"ArrayPattern": [ | ||
"Node", | ||
"Pattern", | ||
"ArrayPattern" | ||
], | ||
"ArrowExpression": [ | ||
@@ -12,3 +18,4 @@ "Node", | ||
"Expression", | ||
"ArrowExpression" | ||
"ArrowExpression", | ||
"Pattern" | ||
], | ||
@@ -18,3 +25,4 @@ "AssignmentExpression": [ | ||
"Expression", | ||
"AssignmentExpression" | ||
"AssignmentExpression", | ||
"Pattern" | ||
], | ||
@@ -24,3 +32,4 @@ "BinaryExpression": [ | ||
"Expression", | ||
"BinaryExpression" | ||
"BinaryExpression", | ||
"Pattern" | ||
], | ||
@@ -40,3 +49,4 @@ "BlockStatement": [ | ||
"Expression", | ||
"CallExpression" | ||
"CallExpression", | ||
"Pattern" | ||
], | ||
@@ -54,3 +64,4 @@ "CatchClause": [ | ||
"Expression", | ||
"ComprehensionExpression" | ||
"ComprehensionExpression", | ||
"Pattern" | ||
], | ||
@@ -60,3 +71,4 @@ "ConditionalExpression": [ | ||
"Expression", | ||
"ConditionalExpression" | ||
"ConditionalExpression", | ||
"Pattern" | ||
], | ||
@@ -90,3 +102,4 @@ "ContinueStatement": [ | ||
"Node", | ||
"Expression" | ||
"Expression", | ||
"Pattern" | ||
], | ||
@@ -128,3 +141,4 @@ "ExpressionStatement": [ | ||
"Expression", | ||
"FunctionExpression" | ||
"FunctionExpression", | ||
"Pattern" | ||
], | ||
@@ -134,3 +148,4 @@ "GeneratorExpression": [ | ||
"Expression", | ||
"GeneratorExpression" | ||
"GeneratorExpression", | ||
"Pattern" | ||
], | ||
@@ -140,3 +155,4 @@ "GraphExpression": [ | ||
"Expression", | ||
"GraphExpression" | ||
"GraphExpression", | ||
"Pattern" | ||
], | ||
@@ -146,3 +162,4 @@ "GraphIndexExpression": [ | ||
"Expression", | ||
"GraphIndexExpression" | ||
"GraphIndexExpression", | ||
"Pattern" | ||
], | ||
@@ -168,3 +185,4 @@ "Identifier": [ | ||
"Expression", | ||
"LetExpression" | ||
"LetExpression", | ||
"Pattern" | ||
], | ||
@@ -179,2 +197,3 @@ "LetStatement": [ | ||
"Expression", | ||
"Pattern", | ||
"Literal" | ||
@@ -185,3 +204,4 @@ ], | ||
"Expression", | ||
"LogicalExpression" | ||
"LogicalExpression", | ||
"Pattern" | ||
], | ||
@@ -191,3 +211,4 @@ "MemberExpression": [ | ||
"Expression", | ||
"MemberExpression" | ||
"MemberExpression", | ||
"Pattern" | ||
], | ||
@@ -197,3 +218,4 @@ "NewExpression": [ | ||
"Expression", | ||
"NewExpression" | ||
"NewExpression", | ||
"Pattern" | ||
], | ||
@@ -206,4 +228,14 @@ "Node": [ | ||
"Expression", | ||
"ObjectExpression" | ||
"ObjectExpression", | ||
"Pattern" | ||
], | ||
"ObjectPattern": [ | ||
"Node", | ||
"Pattern", | ||
"ObjectPattern" | ||
], | ||
"Pattern": [ | ||
"Node", | ||
"Pattern" | ||
], | ||
"Position": [ | ||
@@ -228,3 +260,4 @@ "Position" | ||
"Expression", | ||
"SequenceExpression" | ||
"SequenceExpression", | ||
"Pattern" | ||
], | ||
@@ -250,3 +283,4 @@ "SourceLocation": [ | ||
"Expression", | ||
"ThisExpression" | ||
"ThisExpression", | ||
"Pattern" | ||
], | ||
@@ -266,3 +300,4 @@ "ThrowStatement": [ | ||
"Expression", | ||
"UnaryExpression" | ||
"UnaryExpression", | ||
"Pattern" | ||
], | ||
@@ -272,3 +307,4 @@ "UpdateExpression": [ | ||
"Expression", | ||
"UpdateExpression" | ||
"UpdateExpression", | ||
"Pattern" | ||
], | ||
@@ -298,4 +334,5 @@ "VariableDeclaration": [ | ||
"Expression", | ||
"YieldExpression" | ||
"YieldExpression", | ||
"Pattern" | ||
] | ||
} |
var fs = require("fs") | ||
, esprima = require("esprima"); | ||
, recast = require("recast"); | ||
@@ -11,4 +11,4 @@ var Element = require("./Element"); | ||
var ast = esprima.parse(content, opts); | ||
var ast = recast.parse(content, opts); | ||
return new Element(null, null, ast); | ||
}; |
{ | ||
"name": "eselement" | ||
, "version": "0.1.0" | ||
, "version": "0.1.1" | ||
, "description": "DOM-like wrapper around the Javascript AST" | ||
, "main": "./lib/index.js" | ||
, "dependencies": { | ||
"esprima": "^2.0.0" | ||
"recast": "^0.10.0" | ||
, "esquery": "^0.3.0" | ||
, "escodegen": "^1.6.1" | ||
} | ||
@@ -15,3 +14,2 @@ , "devDependencies": { | ||
, "istanbul": "^0.3.5" | ||
, "pegjs": "^0.8.0" | ||
} | ||
@@ -30,3 +28,5 @@ , "scripts": { | ||
, "esprima" | ||
, "recast" | ||
, "ecmascript" | ||
, "refactor" | ||
] | ||
@@ -33,0 +33,0 @@ , "author": "Ola Holmström" |
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
29212
2
3
11
1199
+ Addedrecast@^0.10.0
+ Addedast-types@0.8.15(transitive)
+ Addedesprima-fb@15001.1001.0-dev-harmony-fb(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedrecast@0.10.43(transitive)
+ Addedsource-map@0.5.7(transitive)
- Removedescodegen@^1.6.1
- Removedesprima@^2.0.0
- Removeddeep-is@0.1.4(transitive)
- Removedescodegen@1.14.3(transitive)
- Removedesprima@2.7.34.0.1(transitive)
- Removedestraverse@4.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfast-levenshtein@2.0.6(transitive)
- Removedlevn@0.3.0(transitive)
- Removedoptionator@0.8.3(transitive)
- Removedprelude-ls@1.1.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedtype-check@0.3.2(transitive)
- Removedword-wrap@1.2.5(transitive)