Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function visitFunctionDefinitionArguments(traverse, node, path, state) {
var end = node.range[1];
if (node.type === Syntax.MethodDefinition) {
node = node.value;
}
for (var index = 0; index < node.params.length; ++index) {
utils.catchup(node.params[index].range[0], state);
traverse(node.params[index], [node].concat(path), state);
utils.catchup(node.params[index].range[1], state);
}
// delete first comma between the last argument and the closing parenthesis
utils.catchup(node.body.range[0], state, function(value) {
var commaIndex = value.substr(0, value.indexOf(")")).indexOf(",");
return commaIndex > -1 ? value.replace(/,/, '') : value;
});
traverse(node.body, [node].concat(path), state);
utils.catchup(end, state);
return false;
function isFunctionNode(node) {
return (node.type == Syntax.FunctionDeclaration ||
node.type == Syntax.FunctionExpression ||
node.type == Syntax.MethodDefinition ||
node.type == Syntax.ArrowFunctionExpression);
}
visitClassFunctionExpression.test = function(node, path, state) {
return node.type === Syntax.FunctionExpression
&& path[0].type === Syntax.MethodDefinition;
};
function isFunctionNode(node) {
return (node.type == Syntax.FunctionDeclaration ||
node.type == Syntax.FunctionExpression ||
node.type == Syntax.MethodDefinition ||
node.type == Syntax.ArrowFunctionExpression);
}
visitClassFunctionExpression.test = function(node, path, state) {
return node.type === Syntax.FunctionExpression
&& path[0].type === Syntax.MethodDefinition;
};
visitClassMethod.test = function(node, path, state) {
return node.type === Syntax.MethodDefinition;
};
visitClassMethodParam.test = function(node, path, state) {
if (!path[0] || !path[1]) {
return;
}
var parentFuncExpr = path[0];
var parentClassMethod = path[1];
return parentFuncExpr.type === Syntax.FunctionExpression
&& parentClassMethod.type === Syntax.MethodDefinition
&& node.type === Syntax.Identifier;
};
function findConstructorIndex(object) {
var classElements = object.body && object.body.body || [];
for (var i = 0; i < classElements.length; i++) {
if (classElements[i].type === Syntax.MethodDefinition &&
classElements[i].key.name === 'constructor') {
return i;
}
}
return -1;
}
visitClassMethod.test = function(node, path, state) {
return node.type === Syntax.MethodDefinition;
};