Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
};
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;
};
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;
}
}
function convertCase (str, fieldCase) {
return fieldCase === 'camel' ? changeCase.camelCase(str)
: fieldCase === 'snake' ? changeCase.snakeCase(str)
: str
}
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;
}
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;
}
}
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;
}
}
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;
}
export function SnakeCase(name: string): string {
return changeCase.snakeCase(name);
}
.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([
{