Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var deferred = getDeferred();
var timeoutId;
var timedout = false;
var retryId;
// the first arument may be an object, if it is not, make an object
var opts;
if (is.obj(port)) {
opts = port;
} else {
opts = makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs);
}
//debug('opts:'+util.inspect(opts);
if (!is.bool(opts.inUse)) {
deferred.reject(new Error('inUse must be a boolean'));
return deferred.promise;
}
if (!is.positiveInt(opts.retryTimeMs)) {
opts.retryTimeMs = RETRYTIME;
debug('set retryTime to default '+RETRYTIME+'ms');
}
if (!is.positiveInt(opts.timeOutMs)) {
opts.timeOutMs = TIMEOUT;
debug('set timeOutMs to default '+TIMEOUT+'ms');
}
function cleanUp() {
if (timeoutId) {