mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Bump to v3.2.0.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
var isFunction = require('../lang/isFunction');
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
@@ -30,8 +28,8 @@ var nativeIsFinite = global.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;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
var isFunction = require('../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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var isFunction = require('../lang/isFunction'),
|
||||
isObject = require('../lang/isObject'),
|
||||
var isObject = require('../lang/isObject'),
|
||||
now = require('../date/now');
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var MapCache = require('../internal/MapCache'),
|
||||
isFunction = require('../lang/isFunction');
|
||||
var MapCache = require('../internal/MapCache');
|
||||
|
||||
/** 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() {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
var isFunction = require('../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() {
|
||||
|
||||
@@ -7,7 +7,6 @@ var before = require('./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
43
function/spread.js
Normal 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);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = spread;
|
||||
@@ -1,5 +1,4 @@
|
||||
var debounce = require('./debounce'),
|
||||
isFunction = require('../lang/isFunction'),
|
||||
isObject = require('../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) {
|
||||
|
||||
Reference in New Issue
Block a user