MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / throttle

Function throttle

MathBox/mathbox-bundle.js:40830–40848  ·  view source on GitHub ↗

* Creates a function that, when executed, will only call the `func` function * at most once per every `wait` milliseconds. Provide 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 throttl

(func, wait, options)

Source from the content-addressed store, hash-verified

40828 * }));
40829 */
40830 function throttle(func, wait, options) {
40831 var leading = true,
40832 trailing = true;
40833
40834 if (!isFunction(func)) {
40835 throw new TypeError;
40836 }
40837 if (options === false) {
40838 leading = false;
40839 } else if (isObject(options)) {
40840 leading = 'leading' in options ? options.leading : leading;
40841 trailing = 'trailing' in options ? options.trailing : trailing;
40842 }
40843 debounceOptions.leading = leading;
40844 debounceOptions.maxWait = wait;
40845 debounceOptions.trailing = trailing;
40846
40847 return debounce(func, wait, debounceOptions);
40848 }
40849
40850 /**
40851 * Creates a function that provides `value` to the wrapper function as its

Callers

nothing calls this directly

Calls 3

debounceFunction · 0.85
isFunctionFunction · 0.70
isObjectFunction · 0.70

Tested by

no test coverage detected