/usr/lib/nodejs/reinterval/index.js is in node-reinterval 1.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 'use strict'
function ReInterval (callback, interval, args) {
var self = this;
this._callback = callback;
this._args = args;
this._interval = setInterval(callback, interval, this._args);
this.reschedule = function (interval) {
// if no interval entered, use the interval passed in on creation
if (!interval)
interval = self._interval;
if (self._interval)
clearInterval(self._interval);
self._interval = setInterval(self._callback, interval, self._args);
};
this.clear = function () {
if (self._interval) {
clearInterval(self._interval);
self._interval = undefined;
}
};
this.destroy = function () {
if (self._interval) {
clearInterval(self._interval);
}
self._callback = undefined;
self._interval = undefined;
self._args = undefined;
};
}
function reInterval () {
if (typeof arguments[0] !== 'function')
throw new Error('callback needed');
if (typeof arguments[1] !== 'number')
throw new Error('interval needed');
var args;
if (arguments.length > 0) {
args = new Array(arguments.length - 2);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i + 2];
}
}
return new ReInterval(arguments[0], arguments[1], args);
}
module.exports = reInterval;
|