How to use the is2.undefined 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 / config-js / index.js View on Github external
var pathToConfigFile = pathToConfigFileIn;
    var idx = pathToConfigFileIn.indexOf('##');
    if (idx > -1 && is.nonEmptyStr(process.env.NODE_ENV)) {
        pathToConfigFile = pathToConfigFileIn.substr(0, idx) +
            process.env.NODE_ENV + pathToConfigFileIn.substr(idx+2);
    }

    // complimentary to have arg checking
    if (!is.nonEmptyStr(pathToConfigFile))
        throw new Error('Bad path to config file: '+pathToConfigFile);
    if (!fs.existsSync(pathToConfigFile))
        throw new Error('Config file is missing: '+pathToConfigFile);
    if (is.defined(region))  assert.ok(is.nonEmptyStr(region));

    // english is the default
    if (is.undefined(region)) region = 'en';

    debug('## sub: pathToConfigFileIn: '+pathToConfigFileIn);
    this.pathToDefaults = path.join(path.dirname(pathToConfigFileIn),
                                    'defaults.js');
    this.pathToConfigFile = pathToConfigFile;
    debug('region: '+region);
    this.region = region;
    var self = this;
    debug('pathToDeafults: '+this.pathToDefaults);

    // set a watch for when the file changes, to reload the file.
    fs.watchFile(this.pathToConfigFile, {persistent: false}, function () {
        self.loadConfig(self.pathToDefaults, self.pathToConfigFile, self.region);
    });

    // we can't wait for the file to change to re-load, so we load it now

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