Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "is_js in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'is_js' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

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];
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();
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
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');
};
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) &&
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;
}
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) {
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');
};
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;
  });
} 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) {

Is your System Free of Underlying Vulnerabilities?
Find Out Now