MCPcopy
hub / github.com/Kong/insomnia / createFlow

Function createFlow

packages/insomnia/bin/yarn-standalone.js:12724–12776  ·  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

12722 * @returns {Function} Returns the new flow function.
12723 */
12724 function createFlow(fromRight) {
12725 return flatRest(function(funcs) {
12726 var length = funcs.length,
12727 index = length,
12728 prereq = LodashWrapper.prototype.thru;
12729
12730 if (fromRight) {
12731 funcs.reverse();
12732 }
12733 while (index--) {
12734 var func = funcs[index];
12735 if (typeof func != 'function') {
12736 throw new TypeError(FUNC_ERROR_TEXT);
12737 }
12738 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
12739 var wrapper = new LodashWrapper([], true);
12740 }
12741 }
12742 index = wrapper ? index : length;
12743 while (++index < length) {
12744 func = funcs[index];
12745
12746 var funcName = getFuncName(func),
12747 data = funcName == 'wrapper' ? getData(func) : undefined;
12748
12749 if (data && isLaziable(data[0]) &&
12750 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
12751 !data[4].length && data[9] == 1
12752 ) {
12753 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
12754 } else {
12755 wrapper = (func.length == 1 && isLaziable(func))
12756 ? wrapper[funcName]()
12757 : wrapper.thru(func);
12758 }
12759 }
12760 return function() {
12761 var args = arguments,
12762 value = args[0];
12763
12764 if (wrapper && args.length == 1 && isArray(value)) {
12765 return wrapper.plant(value).value();
12766 }
12767 var index = 0,
12768 result = length ? funcs[index].apply(this, args) : value;
12769
12770 while (++index < length) {
12771 result = funcs[index].call(this, result);
12772 }
12773 return result;
12774 };
12775 });
12776 }
12777
12778 /**
12779 * Creates a function that wraps `func` to invoke it with optional `this`

Callers 1

yarn-standalone.jsFile · 0.85

Calls 5

flatRestFunction · 0.85
getFuncNameFunction · 0.85
getDataFunction · 0.85
isLaziableFunction · 0.85
isArrayFunction · 0.85

Tested by

no test coverage detected