Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Discovery.prototype.resume = function(name, interval) {
var self = this;
// we need a name that is a string which is not empty
if (!is.nonEmptyStr(name)) {
debug('Discovery.resumeAnnounce error: invalid name: '+inspect(name));
return false;
}
if (!is.positiveint(interval)) interval = DEFAULT_INTERVAL;
// the service has to be known to resume
if (!self.services || !self.services[name]) {
debug('resumeAnnounce error: no entry for \''+name+'\'');
return false;
}
// there can't be an interval task doing announcing to resume
if (self.services[name].intervalId) {
debug('resumeAnnounce error: already announcing \''+name+'\'');
return false;
}
if (interval) self.services[name].annInterval = interval;
// create a function to send the announcement using the closure to retain