How to use the esprima.Syntax.FunctionExpression 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 SAP / ui5-builder / lib / lbt / calls / SapUiDefine.js View on Github external
// assert(String)
			this.name = args[i++].value;
		}

		if ( args[i].type === Syntax.ArrayExpression ) {
			this.dependencyArray = args[i++];
			this.dependencies = this.dependencyArray.elements.map( (elem) => {
				if ( !isString(elem) ) {
					throw new TypeError();
				}
				return ModuleName.resolveRelativeRequireJSName(this.name, elem.value);
			});
			this.dependencyInsertionIdx = this.dependencyArray.elements.length;
		}

		if ( args[i].type === Syntax.FunctionExpression ) {
			this.factory = args[i++];
			params = this.factory.params;
			this.paramNames = params.map( (param) => {
				if ( param.type !== Syntax.Identifier ) {
					throw new TypeError();
				}
				return param.name;
			});
			if ( this.factory.params.length < this.dependencyInsertionIdx ) {
				this.dependencyInsertionIdx = this.factory.params.length;
			}
		}

		// console.log("declared dependencies: " + this.dependencies);
	}
github yanhaijing / template.js / packages / precompiler / src / index.ts View on Github external
function hasContext(type) {
    return [
        Syntax.ArrowFunctionExpression,
        Syntax.FunctionDeclaration,
        Syntax.FunctionExpression,
        Syntax.ForStatement,
        Syntax.ForInStatement,
        Syntax.ForOfStatement,
        Syntax.BlockStatement,
    ].indexOf(type) !== -1;
}