Update _.debounce and _.throttle doc examples and rebuild.

Former-commit-id: fc094e857aeae0ab9581ad56dca894cc96bc7b2e
This commit is contained in:
John-David Dalton
2013-04-19 01:02:36 -07:00
parent a707c2fe8e
commit 038b1bcf7b
8 changed files with 319 additions and 279 deletions

58
dist/lodash.compat.js vendored
View File

@@ -934,6 +934,26 @@
};
}
/**
* Checks if `value` is an array.
*
* @static
* @memberOf _
* @category Objects
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
* @example
*
* (function() { return _.isArray(arguments); })();
* // => false
*
* _.isArray([1, 2, 3]);
* // => true
*/
var isArray = nativeIsArray || function(value) {
return value && typeof value == 'object' && toString.call(value) == arrayClass;
};
/**
* A fallback implementation of `Object.keys` which produces an array of the
* given object's own enumerable property names.
@@ -1406,29 +1426,6 @@
return result;
}
/**
* Checks if `value` is an array.
*
* @static
* @memberOf _
* @category Objects
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
* @example
*
* (function() { return _.isArray(arguments); })();
* // => false
*
* _.isArray([1, 2, 3]);
* // => true
*/
function isArray(value) {
// `instanceof` may cause a memory leak in IE 7 if `value` is a host object
// http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
return (support.argsObject && value instanceof Array) ||
(nativeIsArray ? nativeIsArray(value) : toString.call(value) == arrayClass);
}
/**
* Checks if `value` is a boolean value.
*
@@ -1460,7 +1457,7 @@
* // => true
*/
function isDate(value) {
return value instanceof Date || toString.call(value) == dateClass;
return value ? typeof value == 'object' && toString.call(value) == dateClass : false;
}
/**
@@ -1764,7 +1761,7 @@
// fallback for older versions of Chrome and Safari
if (isFunction(/x/)) {
isFunction = function(value) {
return value instanceof Function || toString.call(value) == funcClass;
return typeof value == 'function' && toString.call(value) == funcClass;
};
}
@@ -1914,7 +1911,7 @@
* // => true
*/
function isRegExp(value) {
return value instanceof RegExp || toString.call(value) == regexpClass;
return value ? typeof value == 'object' && toString.call(value) == regexpClass : false;
}
/**
@@ -4469,6 +4466,11 @@
*
* var lazyLayout = _.debounce(calculateLayout, 300);
* jQuery(window).on('resize', lazyLayout);
*
* jQuery('.postbox').on('click', _.debounce(sendMail, 200, {
* 'leading': true,
* 'trailing': false
* });
*/
function debounce(func, wait, options) {
var args,
@@ -4692,6 +4694,10 @@
*
* var throttled = _.throttle(updatePosition, 100);
* jQuery(window).on('scroll', throttled);
*
* jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
* 'trailing': false
* }));
*/
function throttle(func, wait, options) {
var args,