mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Bump to v3.2.0.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isFunction', '../internal/root'], function(isFunction, root) {
|
||||
define(['../internal/root'], function(root) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -30,8 +30,8 @@ define(['../lang/isFunction', '../internal/root'], function(isFunction, root) {
|
||||
* // => 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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isFunction'], function(isFunction) {
|
||||
define([], function() {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -21,8 +21,8 @@ define(['../lang/isFunction'], function(isFunction) {
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isFunction', '../lang/isObject', '../date/now'], function(isFunction, isObject, now) {
|
||||
define(['../lang/isObject', '../date/now'], function(isObject, now) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -83,7 +83,7 @@ define(['../lang/isFunction', '../lang/isObject', '../date/now'], function(isFun
|
||||
maxWait = false,
|
||||
trailing = true;
|
||||
|
||||
if (!isFunction(func)) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
wait = wait < 0 ? 0 : wait;
|
||||
|
||||
@@ -32,7 +32,7 @@ define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, is
|
||||
length = funcs.length;
|
||||
|
||||
if (!length) {
|
||||
return function() {};
|
||||
return function() { return arguments[0]; };
|
||||
}
|
||||
if (!arrayEvery(funcs, isFunction)) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
|
||||
@@ -32,7 +32,7 @@ define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, is
|
||||
fromIndex = funcs.length - 1;
|
||||
|
||||
if (fromIndex < 0) {
|
||||
return function() {};
|
||||
return function() { return arguments[0]; };
|
||||
}
|
||||
if (!arrayEvery(funcs, isFunction)) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunction) {
|
||||
define(['../internal/MapCache'], function(MapCache) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -57,7 +57,7 @@ define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunc
|
||||
* // => { '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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../lang/isFunction'], function(isFunction) {
|
||||
define([], function() {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -23,7 +23,7 @@ define(['../lang/isFunction'], function(isFunction) {
|
||||
* // => [1, 3, 5]
|
||||
*/
|
||||
function negate(predicate) {
|
||||
if (!isFunction(predicate)) {
|
||||
if (typeof predicate != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
return function() {
|
||||
|
||||
@@ -7,7 +7,6 @@ define(['./before'], function(before) {
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Function
|
||||
* @param {Function} func The function to restrict.
|
||||
* @returns {Function} Returns the new restricted function.
|
||||
|
||||
46
function/spread.js
Normal file
46
function/spread.js
Normal file
@@ -0,0 +1,46 @@
|
||||
define([], function() {
|
||||
|
||||
/** 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);
|
||||
};
|
||||
}
|
||||
|
||||
return spread;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(debounce, isFunction, isObject) {
|
||||
define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -52,7 +52,7 @@ define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(deboun
|
||||
var leading = true,
|
||||
trailing = true;
|
||||
|
||||
if (!isFunction(func)) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
if (options === false) {
|
||||
|
||||
Reference in New Issue
Block a user