lodash.debounce
Advanced tools
Comparing version 4.0.5 to 4.0.6
22
index.js
/** | ||
* lodash 4.0.5 (Custom Build) <https://lodash.com/> | ||
* lodash 4.0.6 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -122,2 +122,3 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
lastThis, | ||
maxWait, | ||
result, | ||
@@ -128,3 +129,3 @@ timerId, | ||
leading = false, | ||
maxWait = false, | ||
maxing = false, | ||
trailing = true; | ||
@@ -138,3 +139,4 @@ | ||
leading = !!options.leading; | ||
maxWait = 'maxWait' in options && nativeMax(toNumber(options.maxWait) || 0, wait); | ||
maxing = 'maxWait' in options; | ||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
@@ -167,3 +169,3 @@ } | ||
return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke); | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
@@ -179,3 +181,3 @@ | ||
return (!lastCallTime || (timeSinceLastCall >= wait) || | ||
(timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait)); | ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); | ||
} | ||
@@ -229,6 +231,8 @@ | ||
} | ||
// Handle invocations in a tight loop. | ||
clearTimeout(timerId); | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
if (maxing) { | ||
// Handle invocations in a tight loop. | ||
clearTimeout(timerId); | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
} | ||
} | ||
@@ -235,0 +239,0 @@ if (timerId === undefined) { |
{ | ||
"name": "lodash.debounce", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"description": "The lodash method `_.debounce` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.debounce v4.0.5 | ||
# lodash.debounce v4.0.6 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.debounce` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#debounce) or [package source](https://github.com/lodash/lodash/blob/4.0.5-npm-packages/lodash.debounce) for more details. | ||
See the [documentation](https://lodash.com/docs#debounce) or [package source](https://github.com/lodash/lodash/blob/4.0.6-npm-packages/lodash.debounce) for more details. |
14279
359