How to use the is_js.array function in is_js

To help you get started, we’ve selected a few is_js 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 finos / cla-bot / cla-bot / contributionVerifier.js View on Github external
module.exports = (config) => {
  const configCopy = Object.assign({}, config);

  // handle the 'legacy' configuration where each type had its own propery
  if (configCopy.contributorListGithubUrl) {
    configCopy.contributors = configCopy.contributorListGithubUrl;
  } else if (config.contributorListUrl) {
    configCopy.contributors = configCopy.contributorListUrl;
  } else if (config.contributorWebhook) {
    configCopy.contributors = configCopy.contributorWebhook;
  }

  if (configCopy.contributors) {
    if (is.array(configCopy.contributors)) {
      console.info('INFO', 'Checking contributors against the list supplied in the .clabot file');
      return contributorArrayVerifier(configCopy.contributors);
    } else if (is.url(configCopy.contributors) && configCopy.contributors.indexOf('api.github.com') !== -1) {
      console.info('INFO', 'Checking contributors against the github URL supplied in the .clabot file');
      return configFileFromGithubUrlVerifier(configCopy.contributors);
    } else if (is.url(configCopy.contributors) && configCopy.contributors.indexOf('?') !== -1) {
      console.info('INFO', 'Checking contributors against the webhook supplied in the .clabot file');
      return webhookVerifier(configCopy.contributors);
    } else if (is.url(configCopy.contributors)) {
      console.info('INFO', 'Checking contributors against the URL supplied in the .clabot file');
      return configFileFromUrlVerifier(configCopy.contributors);
    }
  }
  throw new Error('A mechanism for verifying contributors has not been specified');
};
github finos / cla-bot / src / contributionVerifier.js View on Github external
module.exports = config => {
  const configCopy = Object.assign({}, config);

  // handle the 'legacy' configuration where each type had its own propery
  if (configCopy.contributorListGithubUrl) {
    configCopy.contributors = configCopy.contributorListGithubUrl;
  } else if (config.contributorListUrl) {
    configCopy.contributors = configCopy.contributorListUrl;
  } else if (config.contributorWebhook) {
    configCopy.contributors = configCopy.contributorWebhook;
  }

  if (configCopy.contributors) {
    if (is.array(configCopy.contributors)) {
      console.info(
        "INFO",
        "Checking contributors against the list supplied in the .clabot file"
      );
      return contributorArrayVerifier(configCopy.contributors);
    } else if (
      is.url(configCopy.contributors) &&
      configCopy.contributors.indexOf("api.github.com") !== -1
    ) {
      console.info(
        "INFO",
        "Checking contributors against the github URL supplied in the .clabot file"
      );
      return configFileFromGithubUrlVerifier(configCopy.contributors);
    } else if (
      is.url(configCopy.contributors) &&
github vadimdemedes / mongorito / build / query.js View on Github external
var i = 0;
    var doc = undefined;

    while (doc = docs[i++]) {
      // options.populate is a key-model pair object
      var j = 0;
      var key = undefined;

      while (key = populate[j++]) {
        // model to use when populating the field
        var childModel = options.populate[key];

        var value = doc[key];

        // if value is an array of IDs, loop through it
        if (is.array(value)) {
          // convert each _id
          // to findById op
          value = value.map(childModel.findById, childModel);
        } else {
          value = childModel.findById(value);
        }

        // replace previous ID with actual documents
        doc[key] = yield value;
      }

      // index - 1, because index here is already an index of the next document
      docs[i - 1] = new model(doc, {
        populate: options.populate
      });
    }
github recursivefunk / good-env / index.js View on Github external
get (keyObj, defaultVal) {
      let keys
      let value

      if (is.string(keyObj)) {
        keys = [keyObj]
      } else if (is.array(keyObj)) {
        keys = keyObj.map(k => k.trim())
      } else {
        throw Error(`Invalid key(s) ${keyObj}`)
      }

      keys.some(key => {
        if (ok(process.env[key])) {
          value = process.env[key]
          return true
        }
      })

      if (!ok(value) && typeof ok(defaultVal)) {
        value = defaultVal
      }
github vadimdemedes / mongorito / src / query.js View on Github external
exclude (key, value) {
    if (is.array(key)) {
      let fields = key;
      
      fields.forEach(key => {
        this.exclude(key);
      });
    }
    
    if (is.object(key)) {
      let fields = key;
      let keys = Object.keys(fields);
      
      keys.forEach(key => {
        this.exclude(key, fields[key]);
      });
    }
github umuplus / beems / src / client.js View on Github external
async forward(service, method, data, options) {
        if (is.not.object(options) || is.array(options)) options = this.options.job || {};
        if (is.not.string(service) || is.empty(service)) throw new Error('invalid service');
        else if (is.not.string(method) || is.empty(method)) throw new Error('invalid method');
        else if (is.not.object(data) || is.array(data)) throw new Error('invalid data');
        else if (is.not.object(options) || is.array(options))
            throw new Error('invalid options');

        data._ = method;
        const job = this.services[service].createJob(data);
        for (let config in options)
            if (jobOptions.includes(config) && is.function(job[config]))
                if (is.array(options[config])) job[config](...options[config]);
                else job[config](options[config]);
        await job.save();
        this.logger.info(`${ service }|${ method }|C|${ JSON.stringify(data) }`);
        return job;
    }
github umuplus / beems / src / client.js View on Github external
acceptService(service, options) {
        if (is.not.object(options) || is.array(options)) options = this.options.bee;
        if (is.not.string(service) || is.empty(service))
            throw new Error('invalid service');
        else if (is.not.object(options)) throw new Error('invalid options');

        if (is.not.existy(this.services[service])) {
            this.services[service] = new Queue(service, options);
            this.logger.info(`${ service }|ready(C)`);
        } else this.logger.warn(`${ service }|exists`);
    }
github ColinEberhardt / applause-button / server / handler.js View on Github external
module.exports.getMultiple = lambda(async (event, success) => {
  assert(is.array(event.body), "getMultiple requires an array");
  assert(event.body.every(isurl), "getMultiple requires an array of URLs");

  const items = await getItems(event.body);
  success(items.Responses.Applause);
});
github vadimdemedes / mongorito / src / query.js View on Github external
Query.prototype[method] = function () {
    let args = is.array(arguments[0]) ? arguments[0] : Array.from(arguments);
    
    this.query['$' + method] = args;
    
    return this;
  };
});
github OpenBazaar / openbazaar-desktop / js / models / listing / Item.js View on Github external
if (attrs.price === '') {
      addError('price', app.polyglot.t('itemModelErrors.provideAmount'));
    } else if (is.not.number(attrs.price)) {
      addError('price', app.polyglot.t('itemModelErrors.provideNumericAmount'));
    } else if (attrs.price <= 0) {
      addError('price', app.polyglot.t('itemModelErrors.provideAmountGreaterThanZero'));
    }

    if (!attrs.images.length) {
      addError('images', app.polyglot.t('itemModelErrors.imageRequired'));
    } else if (attrs.images.length > max.images) {
      addError('images', `The number of images cannot exceed ${max.images}`);
    }

    if (attrs.tags) {
      if (is.array(attrs.tags)) {
        if (attrs.tags.length > max.tags) {
          addError('tags',
            app.polyglot.t('itemModelErrors.tooManyTags', { maxTags: max.tags }));
        }

        attrs.tags.forEach((tag, index) => {
          if (is.not.string(tag)) {
            addError('tags', `Tag at index ${index} is not a string and should be.`);
          } else if (tag.length > this.max.tagLength) {
            addError('tags', `Tag ${tag} exceeds the maximum tag length of ${this.max.tagLength}.`);
          }
        });
      } else {
        addError('tags', 'Tags must be provided as an array.');
      }
    }