How to use the is_js.existy 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 pbojinov / request-ip / dist / index.js View on Github external
function getClientIpFromXForwardedFor(value) {
  if (!is.existy(value)) {
    return null;
  }

  if (is.not.string(value)) {
    throw new TypeError("Expected a string, got \"".concat(_typeof(value), "\""));
  } // x-forwarded-for may return multiple IP addresses in the format:
  // "client IP, proxy 1 IP, proxy 2 IP"
  // Therefore, the right-most IP address is the IP address of the most recent proxy
  // and the left-most IP address is the IP address of the originating client.
  // source: http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
  // Azure Web App's also adds a port for some reason, so we'll only use the first part (the IP)


  var forwardedIps = value.split(',').map(function (e) {
    var ip = e.trim();
github vabatta / omx-manager / lib / OmxManager.js View on Github external
OmxManager.prototype.setConfigurations = function setConfigurations(config) {
  // Parameters checking
  if (is.not.object(config)) throw new TypeError('Error: config: must be an object.');
  // Redirect methods
  if (is.existy(config.videosDirectory)) this.setVideosDirectory(config.videosDirectory);
  if (is.existy(config.videosExtension)) this.setVideosExtension(config.videosExtension);
  if (is.existy(config.omxCommand)) this.setOmxCommand(config.omxCommand);
  if (is.existy(config.dbusController)) this.setDbusController(config.dbusController);
};
github pbojinov / request-ip / dist / index.js View on Github external
if (is.existy(req.connection.socket) && is.ip(req.connection.socket.remoteAddress)) {
      return req.connection.socket.remoteAddress;
    }
  }

  if (is.existy(req.socket) && is.ip(req.socket.remoteAddress)) {
    return req.socket.remoteAddress;
  }

  if (is.existy(req.info) && is.ip(req.info.remoteAddress)) {
    return req.info.remoteAddress;
  } // AWS Api Gateway + Lambda


  if (is.existy(req.requestContext) && is.existy(req.requestContext.identity) && is.ip(req.requestContext.identity.sourceIp)) {
    return req.requestContext.identity.sourceIp;
  }

  return null;
}
/**
github dot-microservices / dot / src / client.js View on Github external
socket.send(path, payload, response => {
                    if (is.not.undefined(t_o)) {
                        if (t_o) clearTimeout(t_o);
                        if (is.existy(response) && is.not.string(response)) cb(response);
                        else cb(is.empty(response) ? new Error('INVALID_RESPONSE') : new Error(response));
                    }
                });
            } catch(e) {
github OpenBazaar / openbazaar-desktop / js / models / ServerConfig.js View on Github external
validate(attrs) {
    const errObj = {};
    const addError = (fieldName, error) => {
      errObj[fieldName] = errObj[fieldName] || [];
      errObj[fieldName].push(error);
    };

    if (!is.existy(attrs.name) || is.empty(attrs.name)) {
      addError('name', app.polyglot.t('serverConfigModelErrors.provideValue'));
    }

    if (!is.existy(attrs.serverIp) || is.empty(attrs.serverIp)) {
      addError('serverIp', app.polyglot.t('serverConfigModelErrors.provideValue'));
    } else {
      if (
        !is.ip(attrs.serverIp) &&
        !is.url(attrs.serverIp) &&
        attrs.serverIp !== 'localhost'
      ) {
        addError('serverIp', app.polyglot.t('serverConfigModelErrors.invalidIp'));
      }
    }

    if (!this.isLocalServer()) {
      if (!attrs.username) {
        addError('username', app.polyglot.t('serverConfigModelErrors.provideValue'));
      }
github Albert-Gao / veasy / src / helpers.js View on Github external
export function rulesRunner(value, schema) {
  const fieldState = createNewFieldState();
  fieldState.value = value;

  if (is.existy(value) && is.not.empty(value)) {
    fieldState.status = FieldStatus.ok;
  }

  return runMatchers(handlerMatcher, fieldState, schema);
}
github Albert-Gao / veasy / src / helpers.js View on Github external
formState = undefined
) {
  const fieldState = { [propName]: newFieldState };
  if (formState === undefined) {
    update(fieldState);
    return;
  }

  const oldFieldState = formState[propName];
  const newFieldState1 = {
    ...oldFieldState,
    ...fieldState[propName]
  };

  if (
    is.existy(oldFieldState) && 
    is.existy(newFieldState)
  ) {
    if (!shouldChange(oldFieldState, newFieldState)) return;
  } else {
    return;
  }

  const finalState = {
    ...formState,
    [propName]: { ...newFieldState1 }
  };
  update(checkIsFormOK(schema, finalState));
}
github fernando-mc / serverless-finch / lib / validate.js View on Github external
options.routingRules.forEach(r => {
      if (!is.existy(r.redirect)) {
        validationErrors.push('redirect must be specified for each member of routingRules');
      }

      if (is.existy(r.redirect.replaceKeyPrefixWith) && is.existy(r.redirect.replaceKeyWith)) {
        validationErrors.push(
          'replaceKeyPrefixWith and replaceKeyWith cannot both be specified for a member of member of routingRules'
        );
      }

      const redirectProps = [
        'hostName',
        'httpRedirectCode',
        'protocol',
        'replaceKeyPrefixWith',
        'replaceKeyWith'
      ];
      redirectProps.forEach(p => {
        if (r.redirect[p]) {
          if (p === 'httpRedirectCode') {
            if (!is.integer(r.redirect[p])) {
github Albert-Gao / veasy / src / helpers.js View on Github external
) {
  const fieldState = { [propName]: newFieldState };
  if (formState === undefined) {
    update(fieldState);
    return;
  }

  const oldFieldState = formState[propName];
  const newFieldState1 = {
    ...oldFieldState,
    ...fieldState[propName]
  };

  if (
    is.existy(oldFieldState) && 
    is.existy(newFieldState)
  ) {
    if (!shouldChange(oldFieldState, newFieldState)) return;
  } else {
    return;
  }

  const finalState = {
    ...formState,
    [propName]: { ...newFieldState1 }
  };
  update(checkIsFormOK(schema, finalState));
}