How to use the esprima.Syntax.Identifier function in esprima

To help you get started, we’ve selected a few esprima examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yanhaijing / template.js / packages / precompiler / src / index.ts View on Github external
return params.reduce((prev, param): string[] => {
        if (param.type === Syntax.Identifier) {
            return prev.concat(getIdentifierName(param));
        }
        if (param.type === Syntax.AssignmentPattern) {
            return prev.concat(getAssignmentPatternName(param));
        }
        if (param.type === Syntax.ArrayPattern) {
            return prev.concat(getArrayPatternName(param));
        }
        if (param.type === Syntax.ObjectPattern) {
            return prev.concat(getObjectPatternName(param));
        }
        if (param.type === Syntax.RestElement) {
            return prev.concat(getRestElementName(param));
        }
    }, []);
}
github SAP / ui5-builder / lib / lbt / utils / ASTUtils.js View on Github external
function getPropertyKey(property) {
	if ( property.key.type === Syntax.Identifier ) {
		return property.key.name;
	} else if ( property.key.type === Syntax.Literal ) {
		return String(property.key.value);
	} else {
		throw new Error();
	}
}
github SAP / ui5-builder / lib / lbt / utils / ASTUtils.js View on Github external
function isIdentifier(node, name) {
	if ( node.type != Syntax.Identifier ) {
		return false;
	}
	if ( typeof name == "string" ) {
		return name === node.name;
	}
	for (let i = 0; i < name.length; i++) {
		if ( name[i] === node.name || name[i] === "*" ) {
			return true;
		}
	}
	return false;
}
github SAP / ui5-builder / lib / lbt / calls / SapUiDefine.js View on Github external
this.paramNames = params.map( (param) => {
				if ( param.type !== Syntax.Identifier ) {
					throw new TypeError();
				}
				return param.name;
			});
			if ( this.factory.params.length < this.dependencyInsertionIdx ) {
github yanhaijing / template.js / packages / precompiler / src / index.ts View on Github external
function getAssignmentPatternName(node): string[] {
    if (node.left.type === Syntax.Identifier) {
        return [getIdentifierName(node.left)];
    }
    if (node.left.type === Syntax.ArrayPattern) {
        return getArrayPatternName(node.left);
    }
    if (node.left.type === Syntax.ObjectPattern) {
        return getObjectPatternName(node.left);
    }
}
function getRestElementName(node): string[] {
github sophiebits / es3ify / index.js View on Github external
visitMemberExpression.test = function(node, path, state) {
    return node.type === Syntax.MemberExpression &&
        node.property.type === Syntax.Identifier &&
        reservedDict[node.property.name] === true;
};