stream-chopper
Advanced tools
Comparing version 2.0.0 to 2.1.0
19
index.js
@@ -100,2 +100,16 @@ 'use strict' | ||
this.resetTimer() | ||
// To ensure that the write that caused this stream to be started | ||
// is perfromed in the same tick, call the callback synchronously. | ||
// Note that we can't do this in case the chopper is locked. | ||
cb() | ||
} | ||
StreamChopper.prototype.resetTimer = function (time) { | ||
if (arguments.length > 0) this.time = time | ||
if (this._timer) { | ||
clearTimeout(this._timer) | ||
this._timer = null | ||
} | ||
if (this.time !== -1) { | ||
@@ -108,7 +122,2 @@ this._timer = setTimeout(() => { | ||
} | ||
// To ensure that the write that caused this stream to be started | ||
// is perfromed in the same tick, call the callback synchronously. | ||
// Note that we can't do this in case the chopper is locked. | ||
cb() | ||
} | ||
@@ -115,0 +124,0 @@ |
{ | ||
"name": "stream-chopper", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Chop a single stream of data into a series of readable streams", | ||
@@ -47,5 +47,5 @@ "main": "index.js", | ||
"coordinates": [ | ||
55.777869, | ||
12.592288 | ||
55.778001, | ||
12.592357 | ||
] | ||
} |
@@ -130,3 +130,4 @@ # stream-chopper | ||
Use this property to override it with a new value. The new value will | ||
take effect when the next stream is initialized. | ||
take effect when the next stream is initialized. To change the current | ||
timer, see [`chopper.resetTimer()`](#chopperresettimertime). | ||
@@ -161,2 +162,19 @@ Set to `-1` for no time limit. | ||
### `chopper.resetTimer([time])` | ||
Use this function to reset the current timer (configured via the `time` | ||
config option). Calling this function will force the current timer to | ||
start over. | ||
If the optional `time` argument is provided, this value is used as the | ||
new time. This is equivilent to calling: | ||
```js | ||
chopper.time = time | ||
chopper.resetTimer() | ||
``` | ||
If the function is called with `time` set to `-1`, the current timer is | ||
cancelled and the time limit is disabled for all future streams. | ||
## License | ||
@@ -163,0 +181,0 @@ |
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
14134
191
184