Socket
Socket
Sign inDemoInstall

reinterval

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

15

index.js

@@ -12,4 +12,6 @@ 'use strict'

this.reschedule = function (interval) {
// if no interval entered, use the interval passed in on creation
if (!interval)
interval = self._interval;
var now = Date.now();
if (self._interval)

@@ -24,6 +26,13 @@ clearInterval(self._interval);

self._interval = undefined;
self._callback = undefined;
self._args = undefined;
}
};
this.destroy = function () {
if (self._interval) {
clearInterval(self._interval);
}
self._callback = undefined;
self._interval = undefined;
self._args = undefined;
};
}

@@ -30,0 +39,0 @@

2

package.json
{
"name": "reinterval",
"version": "1.0.2",
"version": "1.1.0",
"description": "reschedulable setInterval for node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

# reInterval
![](https://travis-ci.org/4rzael/reInterval.svg)
![TRAVIS](https://travis-ci.org/4rzael/reInterval.svg)
reschedulable setInterval for node.js
[![NPM](https://nodei.co/npm/reinterval.png?downloads=true&downloadRank=true)](https://nodei.co/npm/reinterval/)
###### Note: Work highly inspired by mcollina [retimer](https://github.com/mcollina/retimer)
Reschedulable setInterval for node.js.
## example
###### Note: Work highly inspired by [mcollina](https://github.com/mcollina)'s [retimer](https://github.com/mcollina/retimer).
## Example
```js

@@ -15,4 +17,6 @@ var reInterval = require('reInterval');

console.log('this should be called after 13s');
}, 10 * 1000)
}, 10 * 1000);
// This will reset/reschedule the interval after 3 seconds, therefore
// the interval callback won't be called for at least 13 seconds.
setTimeout(function () {

@@ -26,16 +30,33 @@ inter.reschedule(10 * 1000);

### reInterval(callback, interval, args)
###`reInterval(callback, interval[, param1, param2, ...])`
This is exactly like setInterval
This is exactly like setInterval.
### interval.reschedule(interval)
_Arguments:_
- `callback`: The callback to be executed repeatedly.
- `interval`: The number of milliseconds (thousandths of a second) that the `reInterval()` function should wait before each call to `callback`.
- `param1, param2, ...`: *(OPTIONAL)* These arguments are passed to the `callback` function.
This function reset the interval and restart it now.
####returns an `interval` object with the following methods:
### interval.clear()
###`interval.reschedule([interval])`
This function clear the interval.
This function resets the `interval` and restarts it now.
_Arguments:_
- `interval`: *(OPTIONAL)* This argument can be used to change the amount of milliseconds to wait before each call to the `callback` passed to the `reInterval()` function.
###`interval.clear()`
This function clears the interval. Can be used to temporarily clear the `interval`, which can be rescheduled at a later time.
###`interval.destroy()`
This function clears the interval, and will also clear the `callback` and `params` passed to reInterval, so calling this essentially just makes this object ready for overwriting with a new `interval` object.
#### Note:
Please ensure that either the `interval.clear()` or `interval.destroy()` function is called before overwriting the `interval` object, because the internal `interval` can continue to run in the background unless cleared.
## license
**MIT**
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc