lodash.debounce
Advanced tools
Comparing version 3.1.0 to 3.1.1
48
index.js
/** | ||
* lodash 3.1.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.1.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
@@ -119,5 +119,5 @@ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
} else if (isObject(options)) { | ||
leading = options.leading; | ||
leading = !!options.leading; | ||
maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); | ||
trailing = 'trailing' in options ? options.trailing : trailing; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
@@ -132,20 +132,24 @@ | ||
} | ||
lastCalled = 0; | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
} | ||
function complete(isCalled, id) { | ||
if (id) { | ||
clearTimeout(id); | ||
} | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (isCalled) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = undefined; | ||
} | ||
} | ||
} | ||
function delayed() { | ||
var remaining = wait - (now() - stamp); | ||
if (remaining <= 0 || remaining > wait) { | ||
if (maxTimeoutId) { | ||
clearTimeout(maxTimeoutId); | ||
} | ||
var isCalled = trailingCall; | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (isCalled) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
complete(trailingCall, maxTimeoutId); | ||
} else { | ||
@@ -157,13 +161,3 @@ timeoutId = setTimeout(delayed, remaining); | ||
function maxDelayed() { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (trailing || (maxWait !== wait)) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
complete(trailing, timeoutId); | ||
} | ||
@@ -208,3 +202,3 @@ | ||
if (isCalled && !timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
args = thisArg = undefined; | ||
} | ||
@@ -211,0 +205,0 @@ return result; |
{ | ||
"name": "lodash.debounce", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "The modern build of lodash’s `_.debounce` as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.debounce v3.1.0 | ||
# lodash.debounce v3.1.1 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.debounce` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#debounce) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.debounce) for more details. | ||
See the [documentation](https://lodash.com/docs#debounce) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.debounce) for more details. |
9820
220