MCPcopy Create free account
hub / github.com/angular/dev-infra / createCallback

Function createCallback

ng-dev/pullapprove/condition_evaluator.ts:234–246  ·  view source on GitHub ↗
(arrowFn: ts.ArrowFunction, context: any)

Source from the content-addressed store, hash-verified

232 throw new Error(`Unsupported expression node type: ${ts.SyntaxKind[node.kind]}`);
233}
234function createCallback(arrowFn: ts.ArrowFunction, context: any): Function {
235 if (arrowFn.parameters.length !== 1) {
236 throw new Error('Only arrow functions with exactly 1 parameter are supported');
237 }
238 const paramName = (arrowFn.parameters[0].name as ts.Identifier).text;
239
240 return (val: any) => {
241 const childContext = Object.create(context);
242 childContext[paramName] = val;
243
244 return evaluateNode(arrowFn.body, childContext);
245 };
246}
247
248/**
249 * Transforms a condition expression from PullApprove that is based on python

Callers 1

evaluateNodeFunction · 0.85

Calls 2

evaluateNodeFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected