MCPcopy Index your code
hub / github.com/deployd/deployd / createFlow

Function createFlow

test-app/public/sinon.js:15702–15754  ·  view source on GitHub ↗

* Creates a `_.flow` or `_.flowRight` function. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new flow function.

(fromRight)

Source from the content-addressed store, hash-verified

15700 * @returns {Function} Returns the new flow function.
15701 */
15702 function createFlow(fromRight) {
15703 return flatRest(function(funcs) {
15704 var length = funcs.length,
15705 index = length,
15706 prereq = LodashWrapper.prototype.thru;
15707
15708 if (fromRight) {
15709 funcs.reverse();
15710 }
15711 while (index--) {
15712 var func = funcs[index];
15713 if (typeof func != 'function') {
15714 throw new TypeError(FUNC_ERROR_TEXT);
15715 }
15716 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
15717 var wrapper = new LodashWrapper([], true);
15718 }
15719 }
15720 index = wrapper ? index : length;
15721 while (++index < length) {
15722 func = funcs[index];
15723
15724 var funcName = getFuncName(func),
15725 data = funcName == 'wrapper' ? getData(func) : undefined;
15726
15727 if (data && isLaziable(data[0]) &&
15728 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
15729 !data[4].length && data[9] == 1
15730 ) {
15731 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
15732 } else {
15733 wrapper = (func.length == 1 && isLaziable(func))
15734 ? wrapper[funcName]()
15735 : wrapper.thru(func);
15736 }
15737 }
15738 return function() {
15739 var args = arguments,
15740 value = args[0];
15741
15742 if (wrapper && args.length == 1 && isArray(value)) {
15743 return wrapper.plant(value).value();
15744 }
15745 var index = 0,
15746 result = length ? funcs[index].apply(this, args) : value;
15747
15748 while (++index < length) {
15749 result = funcs[index].call(this, result);
15750 }
15751 return result;
15752 };
15753 });
15754 }
15755
15756 /**
15757 * Creates a function that wraps `func` to invoke it with optional `this`

Callers 1

sinon.jsFile · 0.85

Calls 4

flatRestFunction · 0.85
isLaziableFunction · 0.85
getFuncNameFunction · 0.70
isArrayFunction · 0.70

Tested by

no test coverage detected