How to use is_js - 10 common examples

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 / src / 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 "${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)
    const forwardedIps = value.split(',').map((e) => {
        const ip = e.trim();
        if (ip.includes(':')) {
            const splitted = ip.split(':');
            // make sure we only use this if it's ipv4 (ip:port)
            if (splitted.length === 2) {
                return splitted[0];
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 vadimdemedes / mongorito / src / mongorito.js View on Github external
hook (when, action, method) {
    // if object is given
    // iterate and call .hook()
    // for each entry
    if (is.object(when)) {
      let hooks = when;
      let keys = Object.keys(hooks);

      keys.forEach(key => {
        let [when, action] = key.split(':');
        let method = hooks[key];

        this.hook(when, action, method);
      });

      return;
    }

    // if array is given
    // iterate and call .hook()
    // for each item
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 Albert-Gao / veasy / src / helpers.js View on Github external
function handleBeforeValidation(fieldValue, handler) {
  if (is.function(handler)) {
    return handler(fieldValue);
  }
  /* eslint no-console: 0 */
  console.warn(`[Veasy]: Expect beforeValidation to be a function \
while the value is ${handler}`);
  return fieldValue;
}
github DextApp / dext / app / main / plugins / plugins.js View on Github external
items.map(i => {
    const icon = {
      type: i && i.icon && i.icon.type,
      path: '',
    };
    if (i.icon && i.icon.path) {
      icon.path = i.icon.path;
      const isBase64 = /data:image\/.*;base64/.test(i.icon.path);
      if (!is.url(i.icon.path) && !isBase64) {
        icon.path = path.resolve(plugin.path, i.icon.path);
      }
    }
    // if an icon isn't set, fallback to the icon.png file in the plugin's directory
    if (!icon.path) {
      icon.path = path.resolve(plugin.path, 'icon.png');
    }
    const newObject = deepAssign({}, i);
    newObject.plugin = {
      path: plugin.path,
      name: plugin.name,
    };
    if (plugin.keyword) {
      newObject.keyword = plugin.keyword;
    }
    if (plugin.action) {
github finos / cla-bot / cla-bot / contributionVerifier.js View on Github external
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 Albert-Gao / veasy / src / helpers.js View on Github external
export function getFieldsValue(schema, state, mustOK = true) {
  const fieldNames = Object.keys(schema);
  let result = {};

  if (is.propertyDefined(schema, 'collectValues')) {
    result = {
      ...getCollectValues(schema.collectValues, state)
    };
  }

  fieldNames.forEach(name => {
    if (is.not.propertyDefined(state, name)) {
      // eslint-disable-next-line no-console
      console.warn(`[veasy]: No ${name} found in state.`);
      return;
    }
    const fieldState = state[name];
    if (mustOK && fieldState.status !== FieldStatus.ok) return;
    result[name] = fieldState.value;
  });
github finos / cla-bot / src / index.js View on Github external
} catch (e) {
    logger.info(
      "Organisation configuration not found, resolving .clabot URL at project level"
    );
    orgConfig = await getReadmeUrl(webhook);
  }

  logger.info(
    `Obtaining .clabot configuration file from ${
      orgConfig.download_url.split("?")[0]
    }`
  );

  const config = await getFile(orgConfig);

  if (!is.json(config)) {
    throw new Error("The .clabot file is not valid JSON");
  }

  // merge with default config options
  const botConfig = Object.assign({}, defaultConfig, config);

  logger.info("Obtaining the list of commits for the pull request");
  const commits = await getCommits(pullRequestUrl);

  logger.info(
    `Total Commits: ${commits.length}, checking CLA status for committers`
  );

  // PRs include the head sha, for comments we have to determine this from the commit history
  let headSha;
  if (webhook.pull_request) {