How to use the is2.positiveNum function in is2

To help you get started, we’ve selected a few is2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stdarg / udp-discovery / index.js View on Github external
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;

is2

A type checking library where each exported function returns either true or false and does not throw. Also added tests.

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis