Comparing version 3.2.0 to 3.2.1
@@ -69,8 +69,16 @@ "use strict"; | ||
function wait() { | ||
timeout = setTimeout(flush, ms); | ||
timeout = setTimeout(_next, ms); | ||
} | ||
// Invoke the function in "pending" state. | ||
function flush() { | ||
if (!pending) | ||
if (pending) | ||
return _next(); | ||
} | ||
// Clear timeout or flush next function call. | ||
function _next() { | ||
// When no pending, remove `timeout`. | ||
if (!pending) { | ||
timeout = undefined; | ||
return; | ||
} | ||
clear(); // Clear existing timeout. | ||
@@ -84,3 +92,3 @@ fn(); // Execute pending function. | ||
if (leading === true) | ||
return flush(); | ||
return _next(); | ||
return wait(); | ||
@@ -87,0 +95,0 @@ } |
{ | ||
"name": "functools", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Utilities for working with functions in JavaScript, with TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
22831
219