mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Rename createComposer to createFlow.
This commit is contained in:
@@ -3214,41 +3214,6 @@
|
|||||||
return new SetCache(values);
|
return new SetCache(values);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a function to compose other functions into a single function.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
||||||
* @returns {Function} Returns the new composer function.
|
|
||||||
*/
|
|
||||||
function createComposer(fromRight) {
|
|
||||||
return function() {
|
|
||||||
var length = arguments.length,
|
|
||||||
index = length,
|
|
||||||
fromIndex = fromRight ? (length - 1) : 0;
|
|
||||||
|
|
||||||
if (!length) {
|
|
||||||
return function() { return arguments[0]; };
|
|
||||||
}
|
|
||||||
var funcs = Array(length);
|
|
||||||
while (index--) {
|
|
||||||
funcs[index] = arguments[index];
|
|
||||||
if (typeof funcs[index] != 'function') {
|
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return function() {
|
|
||||||
var index = fromIndex,
|
|
||||||
result = funcs[index].apply(this, arguments);
|
|
||||||
|
|
||||||
while ((fromRight ? index-- : ++index < length)) {
|
|
||||||
result = funcs[index].call(this, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that produces compound words out of the words in a
|
* Creates a function that produces compound words out of the words in a
|
||||||
* given string.
|
* given string.
|
||||||
@@ -3395,6 +3360,41 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a function to combine other functions into a single function.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||||
|
* @returns {Function} Returns the new flow function.
|
||||||
|
*/
|
||||||
|
function createFlow(fromRight) {
|
||||||
|
return function() {
|
||||||
|
var length = arguments.length,
|
||||||
|
index = length,
|
||||||
|
fromIndex = fromRight ? (length - 1) : 0;
|
||||||
|
|
||||||
|
if (!length) {
|
||||||
|
return function() { return arguments[0]; };
|
||||||
|
}
|
||||||
|
var funcs = Array(length);
|
||||||
|
while (index--) {
|
||||||
|
funcs[index] = arguments[index];
|
||||||
|
if (typeof funcs[index] != 'function') {
|
||||||
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return function() {
|
||||||
|
var index = fromIndex,
|
||||||
|
result = funcs[index].apply(this, arguments);
|
||||||
|
|
||||||
|
while ((fromRight ? index-- : ++index < length)) {
|
||||||
|
result = funcs[index].call(this, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function createForEach(arrayFunc, baseFunc) {
|
function createForEach(arrayFunc, baseFunc) {
|
||||||
return function(collection, iteratee, thisArg) {
|
return function(collection, iteratee, thisArg) {
|
||||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
||||||
@@ -7720,7 +7720,7 @@
|
|||||||
* addSquare(1, 2);
|
* addSquare(1, 2);
|
||||||
* // => 9
|
* // => 9
|
||||||
*/
|
*/
|
||||||
var flow = createComposer();
|
var flow = createFlow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.flow` except that it creates a function that
|
* This method is like `_.flow` except that it creates a function that
|
||||||
@@ -7742,7 +7742,7 @@
|
|||||||
* addSquare(1, 2);
|
* addSquare(1, 2);
|
||||||
* // => 9
|
* // => 9
|
||||||
*/
|
*/
|
||||||
var flowRight = createComposer(true);
|
var flowRight = createFlow(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||||||
|
|||||||
Reference in New Issue
Block a user