mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Adjust the docs of _.forEach, _.after, _.before, _.debounce, & _.throttle. [closes #710] [ci skip]
This commit is contained in:
33
lodash.js
33
lodash.js
@@ -4937,7 +4937,7 @@
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2, 3]).forEach(function(n) { console.log(n); });
|
* _([1, 2, 3]).forEach(function(n) { console.log(n); });
|
||||||
* // => logs each value and returns the array
|
* // => logs each value from left to right and returns the array
|
||||||
*
|
*
|
||||||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
||||||
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
|
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
|
||||||
@@ -5772,7 +5772,7 @@
|
|||||||
* _.forEach(saves, function(type) {
|
* _.forEach(saves, function(type) {
|
||||||
* asyncSave({ 'type': type, 'complete': done });
|
* asyncSave({ 'type': type, 'complete': done });
|
||||||
* });
|
* });
|
||||||
* // => logs 'done saving!' after all saves have completed
|
* // => logs 'done saving!' after the two async saves have completed
|
||||||
*/
|
*/
|
||||||
function after(n, func) {
|
function after(n, func) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
@@ -5793,19 +5793,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that invokes `func`, with the `this` binding and
|
* Creates a function that invokes `func`, with the `this` binding and arguments
|
||||||
* arguments of the created function, until it is called `n` times.
|
* of the created function, while it is called less than `n` times. Subsequent
|
||||||
|
* calls to the created function return the result of the last `func` invocation.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {number} n The number of times `func` may be called.
|
* @param {number} n The number of calls at which `func` is no longer invoked.
|
||||||
* @param {Function} func The function to restrict.
|
* @param {Function} func The function to restrict.
|
||||||
* @returns {Function} Returns the new restricted function.
|
* @returns {Function} Returns the new restricted function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* jQuery('#add').on('click', _.before(5, addContactToList));
|
* jQuery('#add').on('click', _.before(5, addContactToList));
|
||||||
* // => allows adding up to 5 contacts to the list
|
* // => allows adding up to 4 contacts to the list
|
||||||
*/
|
*/
|
||||||
function before(n, func) {
|
function before(n, func) {
|
||||||
var result;
|
var result;
|
||||||
@@ -6013,15 +6014,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that delays the invocation of `func` until after `wait`
|
* Creates a function that delays invoking `func` until after `wait` milliseconds
|
||||||
* milliseconds have elapsed since the last time it was invoked. The created
|
* have elapsed since the last time it was invoked. The created function comes
|
||||||
* function comes with a `cancel` method to cancel delayed invokes. Provide an
|
* with a `cancel` method to cancel delayed invocations. Provide an options
|
||||||
* options object to indicate that `func` should be invoked on the leading
|
* object to indicate that `func` should be invoked on the leading and/or
|
||||||
* and/or trailing edge of the `wait` timeout. Subsequent calls to the
|
* trailing edge of the `wait` timeout. Subsequent calls to the debounced
|
||||||
* debounced function return the result of the last `func` invocation.
|
* function return the result of the last `func` invocation.
|
||||||
*
|
*
|
||||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked on
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
||||||
* the trailing edge of the timeout only if the the debounced function is
|
* on the trailing edge of the timeout only if the the debounced function is
|
||||||
* invoked more than once during the `wait` timeout.
|
* invoked more than once during the `wait` timeout.
|
||||||
*
|
*
|
||||||
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
||||||
@@ -6495,8 +6496,8 @@
|
|||||||
/**
|
/**
|
||||||
* Creates a function that only invokes `func` at most once per every `wait`
|
* Creates a function that only invokes `func` at most once per every `wait`
|
||||||
* milliseconds. The created function comes with a `cancel` method to cancel
|
* milliseconds. The created function comes with a `cancel` method to cancel
|
||||||
* delayed invokes. Provide an options object to indicate that `func` should
|
* delayed invocations. Provide an options object to indicate that `func`
|
||||||
* be invoked on the leading and/or trailing edge of the `wait` timeout.
|
* should be invoked on the leading and/or trailing edge of the `wait` timeout.
|
||||||
* Subsequent calls to the throttled function return the result of the last
|
* Subsequent calls to the throttled function return the result of the last
|
||||||
* `func` call.
|
* `func` call.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user