How to use the is2.nonEmptyString 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
Config.prototype.get = function(propertyName, defaultValue, sep) {
    have(arguments, {propertyName: 'str', sep: 'opt str'});
    debug('config.get of '+propertyName+', def='+defaultValue+', sep='+sep);

    assert.ok(is.nonEmptyStr(propertyName));
    if (!is.nonEmptyStr(sep))  sep = defaultSepChr;

    if (!is.nonEmptyString(propertyName))
        return defaultValue || null;

    // Try to get value from environemnt first
    // We convert name to upper case and if '.' is used as a sep char,
    // replace with "_", so 'logging.name' becomes "LOGGING_NAME"
    var envPropName;
    if (sep === '.')
        envPropName = propertyName.replace(/\./g, '_');
    else
        envPropName = propertyName.replace(new RegExp(sep, 'g'), '_');

    if (!is.nonEmptyStr(envPropName)) {
        debug('Could not remove "."s from '+ propertyName);
    } else {
        envPropName = envPropName.toUpperCase();
    }

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