Bump to v3.2.0.

This commit is contained in:
jdalton
2015-02-12 08:27:43 -08:00
parent d5f4043617
commit b82c7ebc32
92 changed files with 816 additions and 378 deletions

View File

@@ -1,4 +1,3 @@
import isFunction from '../lang/isFunction';
import root from '../internal/root';
/** Used as the `TypeError` message for "Functions" methods. */
@@ -31,8 +30,8 @@ var nativeIsFinite = root.isFinite;
* // => logs 'done saving!' after the two async saves have completed
*/
function after(n, func) {
if (!isFunction(func)) {
if (isFunction(n)) {
if (typeof func != 'function') {
if (typeof n == 'function') {
var temp = n;
n = func;
func = temp;

View File

@@ -1,5 +1,3 @@
import isFunction from '../lang/isFunction';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -21,8 +19,8 @@ var FUNC_ERROR_TEXT = 'Expected a function';
*/
function before(n, func) {
var result;
if (!isFunction(func)) {
if (isFunction(n)) {
if (typeof func != 'function') {
if (typeof n == 'function') {
var temp = n;
n = func;
func = temp;

View File

@@ -1,4 +1,3 @@
import isFunction from '../lang/isFunction';
import isObject from '../lang/isObject';
import now from '../date/now';
@@ -82,7 +81,7 @@ function debounce(func, wait, options) {
maxWait = false,
trailing = true;
if (!isFunction(func)) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = wait < 0 ? 0 : wait;

View File

@@ -33,7 +33,7 @@ function flow() {
length = funcs.length;
if (!length) {
return function() {};
return function() { return arguments[0]; };
}
if (!arrayEvery(funcs, isFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);

View File

@@ -33,7 +33,7 @@ function flowRight() {
fromIndex = funcs.length - 1;
if (fromIndex < 0) {
return function() {};
return function() { return arguments[0]; };
}
if (!arrayEvery(funcs, isFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);

View File

@@ -1,5 +1,4 @@
import MapCache from '../internal/MapCache';
import isFunction from '../lang/isFunction';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -58,7 +57,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* // => { 'user': 'barney' }
*/
function memoize(func, resolver) {
if (!isFunction(func) || (resolver && !isFunction(resolver))) {
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {

View File

@@ -1,5 +1,3 @@
import isFunction from '../lang/isFunction';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -23,7 +21,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* // => [1, 3, 5]
*/
function negate(predicate) {
if (!isFunction(predicate)) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {

View File

@@ -7,7 +7,6 @@ import before from './before';
*
* @static
* @memberOf _
* @type Function
* @category Function
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.

43
function/spread.js Normal file
View File

@@ -0,0 +1,43 @@
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that invokes `func` with the `this` binding of the
* created function and the array of arguments provided to the created
* function much like [Function#apply](http://es5.github.io/#x15.3.4.3).
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
* @returns {*} Returns the new function.
* @example
*
* var spread = _.spread(function(who, what) {
* return who + ' says ' + what;
* });
*
* spread(['Fred', 'hello']);
* // => 'Fred says hello'
*
* // with a Promise
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
* ]);
*
* numbers.then(_.spread(function(x, y) {
* return x + y;
* }));
* // => a Promise of 76
*/
function spread(func) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function(array) {
return func.apply(this, array);
};
}
export default spread;

View File

@@ -1,5 +1,4 @@
import debounce from './debounce';
import isFunction from '../lang/isFunction';
import isObject from '../lang/isObject';
/** Used as the `TypeError` message for "Functions" methods. */
@@ -54,7 +53,7 @@ function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (!isFunction(func)) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (options === false) {