Comparing version 0.0.3 to 0.0.4
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var ArrayExpression, ArrayPattern, ArrowExpression, AssignmentExpression, AssignmentOperator, BinaryExpression, BinaryOperator, BlockStatement, BreakStatement, CallExpression, CatchClause, ComprehensionBlock, ComprehensionExpression, ConditionalExpression, ContinueStatement, DebuggerStatement, Declaration, DoWhileStatement, EmptyStatement, Expression, ExpressionStatement, ForInStatement, ForOfStatement, ForStatement, Function, FunctionDeclaration, FunctionExpression, GeneratorExpression, Identifier, IfStatement, LabeledStatement, Literal, LogicalExpression, LogicalOperator, MemberExpression, NewExpression, Node, ObjectExpression, ObjectPattern, Pattern, Position, Program, Property, PropertyPattern, ReturnStatement, SequenceExpression, SourceLocation, Statement, SwitchCase, SwitchStatement, ThisExpression, ThrowStatement, TryStatement, Types, UnaryExpression, UnaryOperator, UpdateExpression, UpdateOperator, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, builders, isA, isArrayOf, isLiterally, isNullOr, isOneOf, key, value, | ||
var ArrayExpression, ArrayPattern, ArrowExpression, AssignmentExpression, AssignmentOperator, BinaryExpression, BinaryOperator, BlockStatement, BreakStatement, CallExpression, CatchClause, ComprehensionBlock, ComprehensionExpression, ConditionalExpression, ContinueStatement, DebuggerStatement, Declaration, DoWhileStatement, EmptyStatement, Expression, ExpressionStatement, ForInStatement, ForOfStatement, ForStatement, Function, FunctionDeclaration, FunctionExpression, GeneratorExpression, Identifier, IfStatement, LabeledStatement, Literal, LogicalExpression, LogicalOperator, MemberExpression, NewExpression, Node, ObjectExpression, ObjectPattern, Pattern, Position, Program, Properties, Property, PropertyPattern, ReturnStatement, SequenceExpression, SourceLocation, Statement, SwitchCase, SwitchStatement, ThisExpression, ThrowStatement, TryStatement, Types, UnaryExpression, UnaryOperator, UpdateExpression, UpdateOperator, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, builders, globalize, isA, isArrayOf, isLiterally, isNullOr, isOneOf, key, validate, value, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -1149,2 +1149,56 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
Properties = { | ||
ArrayExpression: ['elts', 'loc'], | ||
ArrayPattern: ['elts', 'loc'], | ||
ArrowExpression: ['params', 'defaults', 'rest', 'body', 'isGenerator', 'isExpression', 'loc'], | ||
AssignmentExpression: ['op', 'left', 'right', 'loc'], | ||
BinaryExpression: ['op', 'left', 'right', 'loc'], | ||
BlockStatement: ['body', 'loc'], | ||
BreakStatement: ['label', 'loc'], | ||
CallExpression: ['callee', 'args', 'loc'], | ||
CatchClause: ['arg', 'guard', 'body', 'loc'], | ||
ComprehensionBlock: ['left', 'right', 'isForEach', 'loc'], | ||
ComprehensionExpression: ['body', 'blocks', 'filter', 'loc'], | ||
ConditionalExpression: ['test', 'cons', 'alt', 'loc'], | ||
ContinueStatement: ['label', 'loc'], | ||
DebuggerStatement: ['loc'], | ||
DoWhileStatement: ['body', 'test', 'loc'], | ||
EmptyStatement: ['loc'], | ||
ExpressionStatement: ['expr', 'loc'], | ||
ForStatement: ['init', 'test', 'update', 'body', 'loc'], | ||
ForInStatement: ['left', 'right', 'body', 'isForEach', 'loc'], | ||
ForOfStatement: ['left', 'right', 'body', 'loc'], | ||
FunctionDeclaration: ['id', 'params', 'defaults', 'rest', 'body', 'isGenerator', 'isExpression', 'loc'], | ||
FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body', 'isGenerator', 'isExpression', 'loc'], | ||
GeneratorExpression: ['body', 'blocks', 'filter', 'loc'], | ||
Identifier: ['name', 'loc'], | ||
IfStatement: ['test', 'cons', 'alt', 'loc'], | ||
LabeledStatement: ['label', 'body', 'loc'], | ||
LetExpression: ['head', 'body', 'loc'], | ||
LetStatement: ['head', 'body', 'loc'], | ||
Literal: ['value', 'loc'], | ||
LogicalExpression: ['op', 'left', 'right', 'loc'], | ||
MemberExpression: ['obj', 'prop', 'isComputed', 'loc'], | ||
NewExpression: ['callee', 'args', 'loc'], | ||
ObjectExpression: ['props', 'loc'], | ||
ObjectPattern: ['props', 'loc'], | ||
Program: ['body', 'loc'], | ||
Property: ['key', 'val', 'kind', 'loc'], | ||
PropertyPattern: ['key', 'patt', 'loc'], | ||
ReturnStatement: ['arg', 'loc'], | ||
SequenceExpression: ['exprs', 'loc'], | ||
SwitchCase: ['test', 'cons', 'loc'], | ||
SwitchStatement: ['disc', 'cases', 'isLexical', 'loc'], | ||
ThisExpression: ['loc'], | ||
ThrowStatement: ['arg', 'loc'], | ||
TryStatement: ['body', 'handler', 'fin', 'loc'], | ||
UnaryExpression: ['op', 'arg', 'isPrefix', 'loc'], | ||
UpdateExpression: ['op', 'arg', 'isPrefix', 'loc'], | ||
VariableDeclaration: ['kind', 'dtors', 'loc'], | ||
VariableDeclarator: ['patt', 'init', 'loc'], | ||
WhileStatement: ['test', 'body', 'loc'], | ||
WithStatement: ['obj', 'body', 'loc'], | ||
YieldExpression: ['arg', 'loc'] | ||
}; | ||
Types = { | ||
@@ -1204,3 +1258,3 @@ arrayExpression: ArrayExpression, | ||
module.exports = builders = {}; | ||
builders = module.exports = {}; | ||
@@ -1218,3 +1272,3 @@ for (key in Types) { | ||
module.exports.globalize = function() { | ||
globalize = module.exports.globalize = function() { | ||
var type, _results; | ||
@@ -1228,2 +1282,25 @@ _results = []; | ||
validate = module.exports.validate = function(tree) { | ||
var args, prop, _i, _len, _ref; | ||
args = []; | ||
_ref = Properties[tree.type]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
prop = _ref[_i]; | ||
if (tree[prop] == null) { | ||
args.push(null); | ||
continue; | ||
} | ||
if (Array.isArray(tree[prop])) { | ||
args.push(tree[prop].map(function(el) { | ||
return validate(el); | ||
})); | ||
} else if (typeof tree[prop] === 'object' && (tree[prop].type != null)) { | ||
args.push(validate(tree[prop])); | ||
} else { | ||
args.push(tree[prop]); | ||
} | ||
} | ||
return builders[tree.type[0].toLowerCase() + tree.type.slice(1)].apply(null, args); | ||
}; | ||
}).call(this); |
{ | ||
"name": "astgen", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Generate SpiderMonkey-compatible JavaScript abstract syntax trees", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
38911
1060
0