debounce-stream
Advanced tools
Comparing version 1.0.0 to 1.0.1
28
index.js
@@ -18,4 +18,4 @@ var Transform = require("stream").Transform; | ||
// Track the reference retruned by setTimeout | ||
var timeout = null; | ||
// Track the reference returned by setTimeout | ||
var timeoutId = null; | ||
@@ -39,11 +39,11 @@ // Whether the state is paused or not | ||
// If paused just ignore outputting it for now | ||
if (paused) callback(); | ||
else { | ||
// If we aren't paused, say that there is no value | ||
has_value = false; | ||
// Pause | ||
pause(); | ||
// Pass the data down the stream | ||
callback(null, last_value); | ||
} | ||
if (paused) return callback(); | ||
// If we aren't paused, say that there is no value | ||
has_value = false; | ||
// Pause | ||
pause(); | ||
// Pass the data down the stream | ||
callback(null, last_value); | ||
} | ||
@@ -53,3 +53,3 @@ | ||
stream._flush = function (callback) { | ||
clearTimeout(timeout); | ||
clearTimeout(timeoutId); | ||
if (has_value) this.push(last_value); | ||
@@ -64,5 +64,5 @@ callback(); | ||
// Clear any previous timeout, just in case | ||
clearTimeout(timeout); | ||
clearTimeout(timeoutId); | ||
// Set a new timeout to unpause after the given interval | ||
timeout = setTimeout(unpause, interval); | ||
timeoutId = setTimeout(unpause, interval); | ||
} | ||
@@ -69,0 +69,0 @@ |
{ | ||
"name": "debounce-stream", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A stream that only forwards input once in a given interval", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,3 +26,3 @@ # debounce-stream | ||
``` javascript | ||
var DebounceStream = require("../"); | ||
var DebounceStream = require("debounce-stream"); | ||
var IntervalStream = require("interval-stream"); | ||
@@ -29,0 +29,0 @@ var StreamArray = require("stream-array"); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4299
66