Array_.chunk_.compact_.concat_.difference_.differenceBy_.differenceWith_.drop_.dropRight_.dropRightWhile_.dropWhile_.fill_.findIndex_.findLastIndex_.flatten_.flattenDeep_.flattenDepth_.fromPairs_.head_.indexOf_.initial_.intersection_.intersectionBy_.intersectionWith_.join_.last_.lastIndexOf_.nth_.pull_.pullAll_.pullAllBy_.pullAllWithCollectionDateFunctionLang_.castArray_.clone_.cloneDeep_.cloneDeepWith_.cloneWith_.conformsTo_.eq_.gt_.gte_.isArguments_.isArray_.isArrayBuffer_.isArrayLike_.isArrayLikeObject_.isBoolean_.isBuffer_.isDate_.isElement_.isEmpty_.isEqual_.isEqualWith_.isError_.isFinite_.isFunction_.isInteger_.isLength_.isMap_.isMatch_.isMatchWith_.isNaN_.isNative_.isNil_.isNull_.isNumberMathObjectSeqString_.camelCase_.capitalize_.deburr_.endsWith_.escape_.escapeRegExp_.kebabCase_.lowerCase_.lowerFirst_.pad_.padEnd_.padStart(string ='',length = 0,chars ='')_.parseInt_.repeat(string ='',n = 1)_.replace(string ='',pattern,replacement)_.snakeCase_.split_.startCase_.startsWith_.template_.toLower_.toUpper_.trim_.trimEnd(string ='',chars = whitespace)_.trimStart_.truncate_.unescape_.upperCase_.upperFirstUtil_.attempt_.bindAll_.cond_.conforms_.constant_.defaultTo_.flow_.flowRight_.identity_.iteratee_.matches_.matchesProperty_.method_.methodOf_.mixin_.noConflict_.noop_.nthArg_.over_.overEvery_.overSome_.property_.propertyOf_.range_.rangeRight_.runInContext_.stubArray()_.stubFalse_.stubObject_.stubString_.stubTrue_.times_.toPath_.uniqueIdMethods创建一个去抖动函数,该函数会延迟调用func,直到自上次调用去抖函数后等待几毫秒后。 去抖动函数带有一个取消方法来取消延迟的func调用和一个flush方法来立即调用它们。 提供选项以指示是否应在等待超时的前沿和/或后沿调用func。 func被提供给去抖动函数的最后一个参数调用。 随后调用debounced函数返回最后一次func调用的结果。
注意:如果前导和尾随选项为true,则只有在等待超时期间多次调用debounced函数时,才会在超时的后沿调用func。
如果wait为0且leading为false,则func调用被推迟到下一个tick,类似于超时值为0的setTimeout。
0.1.0
func (功能):去抖功能。 [wait=0] (数字):延迟的毫秒数。 [options={}] (对象):选项对象。 [options.leading=false] (boolean):指定在超时的前沿调用。 [options.maxWait] (数字):最大时间func可以在被调用之前被延迟。 [options.trailing=true] (布尔值):指定在超时的后沿调用。 (功能):返回新的去抖功能。
// Avoid costly calculations while the window size is in flux.
jQuery(window).on('resize', _.debounce(calculateLayout, 150));
// Invoke `sendMail` when clicked, debouncing subsequent calls.
jQuery(element).on('click', _.debounce(sendMail, 300, {
'leading': true,
'trailing': false
}));
// Ensure `batchLog` is invoked once after 1 second of debounced calls.
var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
var source = new EventSource('/stream');
jQuery(source).on('message', debounced);
// Cancel the trailing debounced invocation.
jQuery(window).on('popstate', debounced.cancel);