How to use the is2.nonEmptyStr 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
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;
    //self.services[name].announce = announce;
    // if local is true, the service is local to this process.
    self.services[name].local = announce;

    // if there is an rinfo, copy it and place it on the service
    // we don't need the size parameter, though.
    if (is.obj(rinfo) && is.nonEmptyStr(rinfo.address))
        self.services[name].addr = rinfo.address;

    // set the name property to be read-only - it would be confusing if it
    // changed as it is also the key.
    Object.defineProperty(self.services[name], 'name', {
        value: name,
        writable: false,
        enumerable: true,
        configurable: true
    });

    // since it's new - send an event
    var evName = available ? 'available' : 'unavailable';
    self.emit(evName, name, self.services[name], 'new');

    // update the lanst announcement time to now
github strongloop / supercluster / lib / WorkerRunCommon.js View on Github external
var iterator = function(cmd, cb) {
    // default directorry is the cwd
    if (!is.nonEmptyStr(cmd.dir))  cmd.dir = dir;

    var output = ({stdout:'', stderr:''});
    if (!is.nonEmptyStr(cmd.cmd) || !is.array(cmd.args))
      return debug('Bad command '+inspect(cmd));

    exports.runCmd(cmd.cmd, cmd.args, cmd.dir, output,
    function(err, output, code) {
      if (err) {
        debug(inspect(err.message));
        return cb(err);
      }
      codes.push(code);
      outputs.push(output);
      cb(null);
    });
  };
github strongloop / supercluster / lib / WorkerRunGithub.js View on Github external
exports.gitClone = function(task, targetDir, cb) {

  if (!is.obj(task) || !is.nonEmptyStr(task.user) || !is.nonEmptyStr(task.repo))
    return cb(new Error('Error bad task object: '+inspect(task)));

  if (!is.func(cb))
    return cb(new Error('Bad cb parameter: '+inspect(cb)));

  // assume, if the target directory is present, it was installed.
  // FIXME: This is kinda dumb.
  if (fs.existsSync(targetDir))
    return cb();

  debug('gitClone task: '+inspect(task));
  var url = 'https://github.com/' + task.user + '/' + task.repo;
  debug('gitClone url: '+url);
  exec(['git', 'clone', url], function(err, out, code) {
    if (err) {
      debug('runGithub git clone error: '+inspect(err));
github stdarg / config-js / index.js View on Github external
Config.prototype.setSepChr = function(chr) {
    have(arguments, {chr: 'str'});
    if (is.nonEmptyStr(chr)) {
        defaultSepChr = chr;
        return true;
    }
    return false;
};
github strongloop / supercluster / lib / WorkerRunCommon.js View on Github external
exports.runCmd = function(cmd, args, dir, output, cb) {

  if (!is.nonEmptyStr(cmd))
    return cb(new Error('Bad cmd param: '+inspect(cmd)));

  if (is.nullOrUndefined(args))
    args = [];

  var runInDir = cmd.dir ? cmd.dir : dir;
  if (!is.nonEmptyStr(runInDir))
    return cb(new Error('Bad dir param: '+inspect(runInDir)));

  var errDomain = require('domain').create();
  errDomain.on('error', function(err) {
    debug('Spawned child process error: '+err.message);
    cb(err);
  });

  var child;
  debug('Spawning child process to run '+cmd+', wth args: '+inspect(args));
  errDomain.run(function() {
    child = spawn(cmd, args, {cwd:runInDir, env:process.env});
  });

  child.stdout.on('data', function (data) {
    output.stdout += data;
github strongloop / supercluster / lib / WorkerRunCommon.js View on Github external
exports.runCmd = function(cmd, args, dir, output, cb) {

  if (!is.nonEmptyStr(cmd))
    return cb(new Error('Bad cmd param: '+inspect(cmd)));

  if (is.nullOrUndefined(args))
    args = [];

  var runInDir = cmd.dir ? cmd.dir : dir;
  if (!is.nonEmptyStr(runInDir))
    return cb(new Error('Bad dir param: '+inspect(runInDir)));

  var errDomain = require('domain').create();
  errDomain.on('error', function(err) {
    debug('Spawned child process error: '+err.message);
    cb(err);
  });

  var child;
github stdarg / config-js / index.js View on Github external
Config.prototype.getByRegion = function(propertyName, defaultValue, sep) {
    have(arguments, {propertyName: 'str', sep: 'opt str'});

    assert.ok(is.nonEmptyStr(propertyName));
    if (this.region === undefined || propertyName === undefined)
        return defaultValue;

    propertyName = this.region + '.' + propertyName;
    return this.get(propertyName, defaultValue, sep);
};
github strongloop / supercluster / lib / WorkerRunFile.js View on Github external
exports.spawnChild = function(task, dir, output, cb) {

  if (!is.obj(task) || !is.str(task.fileName))
    return cb(new Error('Bad task object: '+inspect(task)));

  if (!is.nonEmptyStr(dir))
    return cb(new Error('Bad dir object: '+inspect(task)));

  if (!is.obj(output) || !is.str(output.stdout) || !is.str(output.stderr))
    return cb(new Error('Bad output object: '+inspect(output)));

  var args = task.args;
  args.unshift(task.fileName);
  var child = spawn('node', args, {cwd:dir, env:process.env});
  debug('Spawned child process to run file.');

  child.stdout.on('data', function (data) {
    output.stdout += data;
    debug('stdout: ' + data);
  });

  child.stderr.on('data', function (data) {

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