Bump to v3.4.0.

This commit is contained in:
jdalton
2015-02-28 23:03:50 -08:00
parent cc16e113c2
commit 4881dda9d1
49 changed files with 868 additions and 588 deletions

View File

@@ -1,8 +1,4 @@
var arrayEvery = require('../internal/arrayEvery'),
baseIsFunction = require('../internal/baseIsFunction');
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
var createComposer = require('../internal/createComposer');
/**
* Creates a function that returns the result of invoking the provided
@@ -16,37 +12,14 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* @returns {Function} Returns the new function.
* @example
*
* function add(x, y) {
* return x + y;
* }
*
* function square(n) {
* return n * n;
* }
*
* var addSquare = _.flow(add, square);
* var addSquare = _.flow(_.add, square);
* addSquare(1, 2);
* // => 9
*/
function flow() {
var funcs = arguments,
length = funcs.length;
if (!length) {
return function() { return arguments[0]; };
}
if (!arrayEvery(funcs, baseIsFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var index = 0,
result = funcs[index].apply(this, arguments);
while (++index < length) {
result = funcs[index].call(this, result);
}
return result;
};
}
var flow = createComposer();
module.exports = flow;