How to use the is_js.string 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 vabatta / omx-manager / lib / OmxInstance.js View on Github external
Object.keys(args).forEach(function forEachArgsKey(key) {
    // Get the value of the key
    var value = args[key];
    // Validity check to push only string, number and boolean values command line arguments
    var validValue = is.string(value) || is.number(value) || is.boolean(value);
    // Validity check
    if (validValue && is.truthy(value)) {
      // Check for custom handling keys
      if (is.not.inArray(key, keysIgnored)) {
        // Push the key
        argsToSpawn.push(key);
        // Push value for string and number values
        if (is.string(value)) argsToSpawn.push(value);
        else if (is.number(value)) argsToSpawn.push(value.toString());
      }
      // Check if should handle loop
      else if (is.equal(key, '--loop')) {
        self._configurations.loop = true;
      }
    }
  });
github fernando-mc / serverless-finch / lib / validate.js View on Github external
function validateClient(serverless, options) {
  const validationErrors = [];

  // path to website files must exist
  const distributionFolder = options.distributionFolder || path.join('client/dist');
  const clientPath = path.join(serverless.config.servicePath, distributionFolder);
  if (!serverless.utils.dirExistsSync(clientPath)) {
    validationErrors.push(`Could not find '${clientPath}' folder in your project root`);
  }

  // bucketName must be a string
  if (!is.string(options.bucketName)) {
    validationErrors.push('Please specify a bucket name for the client in serverless.yml');
  }

  // check header options
  if (options.objectHeaders) {
    if (!is.object(options.objectHeaders)) {
      validationErrors.push('objectHeaders must be an object');
    }

    Object.keys(options.objectHeaders).forEach(p => {
      if (!is.array(options.objectHeaders[p])) {
        validationErrors.push('Each member of objectHeaders must be an array');
      }

      options.objectHeaders[p].forEach(h => {
        if (!(is.existy(h.name) && is.string(h.name))) {
github vadimdemedes / mongorito / src / mongorito.js View on Github external
static get _collection () {
    if (is.string(this.prototype.collection)) {
      return Mongorito._collection(this._db, this.prototype.collection);
    }
    
    // get collection name
    // from the "collection" property
    // or generate the default one
    let defaultName = pluralize(this.name).toLowerCase();
    let name = result(this.prototype, 'collection', defaultName);

    // save collection name
    // to avoid the same check in future
    this.prototype.collection = name;

    return Mongorito._collection(this._db, name);
  }
github recursivefunk / good-env / index.js View on Github external
return items.every(item => {
        if (is.string(item)) {
          if (this.ok(item)) {
            return true
          } else {
            throw Error(`No environment configuration for var "${item}"`)
          }
        } else if (is.json(item)) {
          const key = Object.keys(item)[0]
          const type = item[key].type
          const validator = item[key].ok

          if (type && !validType(type)) {
            throw Error(`Invalid expected type "${type}"`)
          } else {
            const kit = getKit(type)
            const val = kit.getter(key)
            const result = kit.validator(val)
github dot-microservices / dot-rest / src / client.js View on Github external
this._registry.get(service).then(address => {
                if (is.string(address) && is.not.empty(address) && address.includes(':')) {
                    let url = `http://${ address }/${ service }`;
                    if (is.string(method)) url += `/${ method }`;
                    const request = { method: httpMethod, url };
                    options = is.object(options) && is.not.array(options) ? options : {};
                    if (httpMethod === 'get' || httpMethod === 'delete')
                        request.params = options;
                    else request.data = options;
                    axios(request)
                        .then(r => {
                            this._logger.info(request, 'success');
                            resolve(r);
                        })
                        .catch(e => {
                            this._logger.error({ httpMethod, service, method, options }, e.message);
                            reject(e);
                        });
github OpenBazaar / openbazaar-desktop / js / views / search / Search.js View on Github external
buildProviderUpdate(data) {
    const update = {};
    const urlTypes = [];

    if (data.name && is.string(data.name)) update.name = data.name;
    if (data.logo && is.url(data.logo)) update.logo = data.logo;
    if (data.links) {
      if (is.url(data.links.vendors)) {
        update.vendors = data.links.vendors;
        urlTypes.push('vendors');
      }
      if (is.url(data.links.listings)) {
        update.listings = data.links.listings;
        urlTypes.push('listings');
      }
      if (is.url(data.links.reports)) {
        update.reports = data.links.reports;
        urlTypes.push('reports');
      }
      if (data.links.tor) {
        if (is.url(data.links.tor.listings)) {
github fernando-mc / serverless-finch / lib / validate.js View on Github external
if (is.inArray('routingRules', clientConfigOptions)) {
      validationErrors.push('routingRules cannot be specified with redirectAllRequestsTo');
    }

    if (!is.existy(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push(
        'redirectAllRequestsTo.hostName is required if redirectAllRequestsTo is specified'
      );
    }
    if (!is.string(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push('redirectAllRequestsTo.hostName must be a string');
    }

    if (options.redirectAllRequestsTo.protocol) {
      if (!is.string(options.redirectAllRequestsTo.protocol)) {
        validationErrors.push('redirectAllRequestsTo.protocol must be a string');
      }
      if (!is.inArray(options.redirectAllRequestsTo.protocol.toLowerCase(), ['http', 'https'])) {
        validationErrors.push('redirectAllRequestsTo.protocol must be either http or https');
      }
    }
  }

  if (options.routingRules) {
    if (!is.array(options.routingRules)) {
      validationErrors.push('routingRules must be a list');
    }

    options.routingRules.forEach(r => {
      if (!is.existy(r.redirect)) {
        validationErrors.push('redirect must be specified for each member of routingRules');
github dot-microservices / dot-rest / src / server.js View on Github external
_configureService(service) {
        let configure = is.function(service) && is.function(service._configure) ? service._configure() : {};
        if (is.not.object(configure) || is.array(configure)) configure = {};
        for (let cfg of Object.keys(configure)) {
            if (cfg.startsWith('_') || is.not.function(service[cfg])) delete configure[cfg];
            if (is.not.array(configure[cfg])) delete configure[cfg];
            else if (is.string(configure[cfg][0]))
                configure[cfg] = [ [ configure[cfg][0], configure[cfg][1] || Base._unCamelCase(cfg) ] ];
        }
        for (let method of Object.getOwnPropertyNames(service)) {
            if (!method || method.startsWith('_') || this._ignoredProperties.includes(method)) continue;
            if (is.not.function(service[method]) || is.array(configure[method])) continue;

            configure[method] = [ [ '*', `/${ method }` ] ];
        }
        return configure;
    }
github vadimdemedes / mongorito / src / query.js View on Github external
sort (key, value) {
    if (is.object(key)) {
      assign(this.options.sort, key);
    }
    
    if (is.string(key) && value) {
      this.options.sort[key] = value;
    }

    return this;
  }
github dot-microservices / dot-rest / src / client.js View on Github external
this._registry.get(service).then(address => {
                if (is.string(address) && is.not.empty(address) && address.includes(':')) {
                    let url = `http://${ address }/${ service }`;
                    if (is.string(method)) url += `/${ method }`;
                    const request = { method: httpMethod, url };
                    options = is.object(options) && is.not.array(options) ? options : {};
                    if (httpMethod === 'get' || httpMethod === 'delete')
                        request.params = options;
                    else request.data = options;
                    axios(request)
                        .then(r => {
                            this._logger.info(request, 'success');
                            resolve(r);
                        })
                        .catch(e => {
                            this._logger.error({ httpMethod, service, method, options }, e.message);
                            reject(e);
                        });
                } else {
                    this._logger.error({ httpMethod, service, method, options }, 'unknown service');