Update builds, vendors, and docs.

Former-commit-id: 67aec5a64de61ac2b8948b31315395a727c10071
This commit is contained in:
John-David Dalton
2013-04-05 09:04:01 -07:00
parent 8f3eeefafd
commit 7f637e4acc
14 changed files with 343 additions and 264 deletions

85
dist/lodash.js vendored
View File

@@ -552,6 +552,7 @@
* @param {Object} [options1, options2, ...] The compile options object(s).
* arrays - A string of code to determine if the iterable is an array or array-like.
* useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
* useKeys - A boolean to specify using `_.keys` for own property iteration.
* args - A string of comma separated arguments the iteration function will accept.
* top - A string of code to execute before the iteration branches.
* loop - A string of code to execute in the object loop.
@@ -1060,7 +1061,9 @@
* @returns {Mixed} Returns the key of the found element, else `undefined`.
* @example
*
* _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; });
* _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) {
* return num % 2 == 0;
* });
* // => 'b'
*/
function findKey(object, callback, thisArg) {
@@ -1334,11 +1337,8 @@
function isEqual(a, b, callback, thisArg, stackA, stackB) {
// used to indicate that when comparing objects, `a` has at least the properties of `b`
var whereIndicator = callback === indicatorObject;
if (callback && !whereIndicator) {
callback = (typeof thisArg == 'undefined')
? callback
: lodash.createCallback(callback, thisArg, 2);
if (typeof callback == 'function' && !whereIndicator) {
callback = lodash.createCallback(callback, thisArg, 2);
var result = callback(a, b);
if (typeof result != 'undefined') {
return !!result;
@@ -2280,7 +2280,9 @@
* @returns {Mixed} Returns the found element, else `undefined`.
* @example
*
* _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; });
* _.find([1, 2, 3, 4], function(num) {
* return num % 2 == 0;
* });
* // => 2
*
* var food = [
@@ -4228,44 +4230,53 @@
/**
* Creates a function that will delay the execution of `func` until after
* `wait` milliseconds have elapsed since the last time it was invoked. Pass
* `true` for `immediate` to cause debounce to invoke `func` on the leading,
* instead of the trailing, edge of the `wait` timeout. Subsequent calls to
* the debounced function will return the result of the last `func` call.
* an `options` object to indicate that `func` should be invoked on the leading
* and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced
* function will return the result of the last `func` call.
*
* @static
* @memberOf _
* @category Functions
* @param {Function} func The function to debounce.
* @param {Number} wait The number of milliseconds to delay.
* @param {Boolean} immediate A flag to indicate execution is on the leading
* edge of the timeout.
* @param {Object} options The options object.
* [leading=false] A boolean to specify execution on the leading edge of the timeout.
* [trailing=true] A boolean to specify execution on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* var lazyLayout = _.debounce(calculateLayout, 300);
* jQuery(window).on('resize', lazyLayout);
*/
function debounce(func, wait, immediate) {
function debounce(func, wait, options) {
var args,
result,
thisArg,
timeoutId;
timeoutId,
trailing = true;
function delayed() {
timeoutId = null;
if (!immediate) {
if (trailing) {
result = func.apply(thisArg, args);
}
}
if (options === true) {
var leading = true;
trailing = false;
} else if (options) {
leading = options.leading;
trailing = options.trailing;
}
return function() {
var isImmediate = immediate && !timeoutId;
var isLeading = leading && !timeoutId;
args = arguments;
thisArg = this;
clearTimeout(timeoutId);
timeoutId = setTimeout(delayed, wait);
if (isImmediate) {
if (isLeading) {
result = func.apply(thisArg, args);
}
return result;
@@ -4435,39 +4446,57 @@
}
/**
* Creates a function that, when executed, will only call the `func`
* function at most once per every `wait` milliseconds. If the throttled
* function is invoked more than once during the `wait` timeout, `func` will
* also be called on the trailing edge of the timeout. Subsequent calls to the
* throttled function will return the result of the last `func` call.
* Creates a function that, when executed, will only call the `func` function
* at most once per every `wait` milliseconds. If the throttled function is
* invoked more than once during the `wait` timeout, `func` will also be called
* on the trailing edge of the timeout. Pass an `options` object to indicate
* that `func` should be invoked on the leading and/or trailing edge of the
* `wait` timeout. Subsequent calls to the throttled function will return
* the result of the last `func` call.
*
* @static
* @memberOf _
* @category Functions
* @param {Function} func The function to throttle.
* @param {Number} wait The number of milliseconds to throttle executions to.
* @param {Object} options The options object.
* [leading=true] A boolean to specify execution on the leading edge of the timeout.
* [trailing=true] A boolean to specify execution on the trailing edge of the timeout.
* @returns {Function} Returns the new throttled function.
* @example
*
* var throttled = _.throttle(updatePosition, 100);
* jQuery(window).on('scroll', throttled);
*/
function throttle(func, wait) {
function throttle(func, wait, options) {
var args,
result,
thisArg,
timeoutId,
lastCalled = 0;
lastCalled = 0,
leading = true,
trailing = true;
function trailingCall() {
lastCalled = new Date;
timeoutId = null;
result = func.apply(thisArg, args);
if (trailing) {
result = func.apply(thisArg, args);
}
}
if (options === false) {
leading = false;
} else if (options) {
leading = options.leading;
trailing = options.trailing;
}
return function() {
var now = new Date,
remaining = wait - (now - lastCalled);
var now = new Date;
if (!timeoutId && !leading) {
lastCalled = now;
}
var remaining = wait - (now - lastCalled);
args = arguments;
thisArg = this;