How to use the change-case.snakeCase function in change-case

To help you get started, we’ve selected a few change-case 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 taskcluster / taskcluster-tools / src / components / AwsProvisionerHealthTable / index.jsx View on Github external
sort = (a, b) => {
    const { sortBy } = this.state;
    // TODO: Remove snake-case logic when API changes to be consistent
    // e.g., https://ec2-manager.taskcluster.net/v1/worker-types/gecko-1-b-linux/health
    const elem1 = a[camelCase(sortBy)] || a[snakeCase(sortBy)];
    const elem2 = b[camelCase(sortBy)] || b[snakeCase(sortBy)];

    if (!sortBy || sortBy === 'None') {
      return a;
    } else if (Number.isInteger(elem1)) {
      const diff = elem1 - elem2;

      if (diff === 0) {
        return 0;
      }

      return diff < 0 ? 1 : -1;
    }

    return elem1.localeCompare(elem2);
  };
github bonustrack / steemconnect / helpers / operation.js View on Github external
const normalize = async (type, query) => {
  const snakeCaseType = changeCase.snakeCase(type);
  if (hasIn(helperOperations, snakeCaseType) && typeof helperOperations[snakeCaseType].normalize === 'function') {
    return await helperOperations[snakeCaseType].normalize(query);
  }
  return query;
};
github Shopify / graphql-tools-web / packages / graphql-typescript-definitions / src / print / schema / index.ts View on Github external
function enumMemberName(name: string, format?: EnumFormat) {
  switch (format) {
    case EnumFormat.CamelCase:
      return camelCase(name);
    case EnumFormat.PascalCase:
      return pascalCase(name);
    case EnumFormat.SnakeCase:
      return snakeCase(name);
    case EnumFormat.ScreamingSnakeCase:
      return snakeCase(name).toUpperCase();
    default:
      return name;
  }
}
github cognitom / momy / lib / defs.js View on Github external
function convertCase (str, fieldCase) {
  return fieldCase === 'camel' ? changeCase.camelCase(str)
    : fieldCase === 'snake' ? changeCase.snakeCase(str)
    : str
}
github bonustrack / steemconnect / src / components / Sign.js View on Github external
getPlaceholder = (type) => {
    let Placeholder = SignPlaceholderDefault;
    Placeholder = (type === 'comment') ? SignPlaceholderComment : Placeholder;
    Placeholder = (changeCase.snakeCase(type) === 'profile_update') ? SignPlaceholderNonFiltered : Placeholder;
    Placeholder = (['transfer', 'delegate_vesting_shares', 'undelegate_vesting_shares'].includes(changeCase.snakeCase(type))) ? SignPlaceholderTransferDelegate : Placeholder;
    return Placeholder;
  }
github Shopify / graphql-tools-web / packages / graphql-typescript-definitions / src / print / schema / index.ts View on Github external
function enumMemberName(name: string, format?: EnumFormat) {
  switch (format) {
    case EnumFormat.CamelCase:
      return camelCase(name);
    case EnumFormat.PascalCase:
      return pascalCase(name);
    case EnumFormat.SnakeCase:
      return snakeCase(name);
    case EnumFormat.ScreamingSnakeCase:
      return snakeCase(name).toUpperCase();
    default:
      return name;
  }
}
github Shopify / quilt / packages / statsd / src / client.ts View on Github external
private normalizeTags(tags: Tags = []) {
    if (Array.isArray(tags)) {
      return tags;
    }

    const output: Record = {};

    for (const [key, value] of Object.entries(tags)) {
      const newValue = value == null ? UNKNOWN : String(value);

      if (this.options.snakeCase) {
        output[snakeCase(key)] = newValue;
      } else {
        output[key] = newValue;
      }
    }

    return output;
  }
}
github bonustrack / steemconnect / src / components / GenerateLink.js View on Github external
isRequiredField = (field) => {
    const { operation } = this.state;
    if (Object.keys(helperOperations).includes(changeCase.snakeCase(operation))) {
      const optionalFields = helperOperations[changeCase.snakeCase(operation)].optionalFields;
      if (optionalFields && optionalFields.includes(field)) {
        return false;
      }
    }

    const author = authorOperations[changeCase.snakeCase(operation)];
    if (author && author.includes(field)) {
      return false;
    }
    return true;
  }
github artifacthealth / hydrate-mongodb / src / config / namingStrategies.ts View on Github external
export function SnakeCase(name: string): string {

        return changeCase.snakeCase(name);
    }
github htmlburger / wpemerge-theme / resources / build / rebrand / steps.js View on Github external
.then((answers) => {
    const tokens = {
      'WP Emerge Starter Theme': answers.name,
      'WP Emerge Starter Plugin': answers.name,
      'MyApp': pascalCase(answers.namespace),
      'MY_APP': constantCase(answers.namespace),
      'my_app': snakeCase(answers.namespace),
    };

    log('');
    log('The following changes will be applied:');
    log('--------------------------------------');
    log(`WP Emerge Starter Theme/Plugin => ${chalk.cyan(tokens['WP Emerge Starter Theme'])}`);
    log(`MyApp                          => ${chalk.cyan(tokens['MyApp'])}`);
    log(`MY_APP                         => ${chalk.cyan(tokens['MY_APP'])}`);
    log(`my_app                         => ${chalk.cyan(tokens['my_app'])}`);
    log('--------------------------------------');
    log('');
    log(chalk.yellow('WARNING: This is a one-time replacement only. Once applied it cannot be undone or updated automatically.'));

    return inquirer
      .prompt([
        {