MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / addInterceptor

Function addInterceptor

web/static/bower_components/angular/angular.js:14393–14424  ·  view source on GitHub ↗
(parsedExpression, interceptorFn)

Source from the content-addressed store, hash-verified

14391 }
14392
14393 function addInterceptor(parsedExpression, interceptorFn) {
14394 if (!interceptorFn) return parsedExpression;
14395 var watchDelegate = parsedExpression.$$watchDelegate;
14396
14397 var regularWatch =
14398 watchDelegate !== oneTimeLiteralWatchDelegate &&
14399 watchDelegate !== oneTimeWatchDelegate;
14400
14401 var fn = regularWatch ? function regularInterceptedExpression(scope, locals, assign, inputs) {
14402 var value = parsedExpression(scope, locals, assign, inputs);
14403 return interceptorFn(value, scope, locals);
14404 } : function oneTimeInterceptedExpression(scope, locals, assign, inputs) {
14405 var value = parsedExpression(scope, locals, assign, inputs);
14406 var result = interceptorFn(value, scope, locals);
14407 // we only return the interceptor's result if the
14408 // initial value is defined (for bind-once)
14409 return isDefined(value) ? result : value;
14410 };
14411
14412 // Propagate $$watchDelegates other then inputsWatchDelegate
14413 if (parsedExpression.$$watchDelegate &&
14414 parsedExpression.$$watchDelegate !== inputsWatchDelegate) {
14415 fn.$$watchDelegate = parsedExpression.$$watchDelegate;
14416 } else if (!interceptorFn.$stateful) {
14417 // If there is an interceptor, but no watchDelegate then treat the interceptor like
14418 // we treat filters - it is assumed to be a pure function unless flagged with $stateful
14419 fn.$$watchDelegate = inputsWatchDelegate;
14420 fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression];
14421 }
14422
14423 return fn;
14424 }
14425 }];
14426}
14427

Callers 1

$ParseProviderFunction · 0.85

Calls 1

isDefinedFunction · 0.85

Tested by

no test coverage detected