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.addNew = function(name, userData, interval, available,
announce, rinfo) {
var self = this;
debug('addNew');
if (!is.nonEmptyStr(name)) {
debug('addNew error: missing name: '+inspect(name));
return false;
}
if (!userData) {
debug('addNew error: no userData: what is being announced?');
return false;
}
// add defaults, if needed
if (!is.positiveNum(interval)) interval = DEFAULT_INTERVAL;
if (!available) available = true;
// create the services storage if need be
if (!self.services) self.services = {};
// The entry should not already exist
if (self.services[name]) {
debug('addNew for \''+name+'\', but it already exists.');
return false;
}
self.services[name] = {};
self.services[name].name = name;
self.services[name].interval = interval;
self.services[name].data = userData;
self.services[name].available = available;