variable-name-conversion
Version:
To easily convert a variable name to camelCase, kebab-case, etc.
105 lines (104 loc) • 2.42 kB
TypeScript
/**
* Variable name conversion helper class.
*
* Used to easily convert a variable name to camelCase, kebab-case, and so on.
*/
export default class VariableName {
keepCase: boolean;
/**
* @param str - Any form of the variable name to be converted.
* @param keepCase - Should it maintain case sensitivity when converting to kebab-case, snake_case, etc.?
*/
constructor(str: string, keepCase?: boolean);
/**
* Reset the value.
* @param str - Any form of the variable name.
*/
set value(str: string);
/**
* Convert to kebab-case.
*/
get kebab(): string;
/**
* Convert to snake_case.
*/
get snake(): string;
/**
* Convert to CONSTANT_CASE.
*/
get const(): string;
/**
* Convert to PascalCase.
*/
get pascal(): string;
/**
* Convert to camelCase.
*/
get camel(): string;
/**
* Convert to lowercase without any separators.
*/
get lower(): string;
/**
* Convert to UPPERCASE without any separators.
*/
get upper(): string;
/**
* Convert to word case, separated by spaces, all in lowercase.
*/
get words(): string;
/**
* Convert to Sentence case, separated by spaces, with only the first letter of the sentence capitalized.
*/
get sentence(): string;
/**
* Convert to Title Case, separated by spaces, with all first letters of words capitalized.
*/
get title(): string;
/**
* Convert to --css-custom-property-name-form, which is kebab-case with two dashes as the prefix.
*/
get cssVar(): string;
/**
* Convert to css-property-name-form / -webkit-css-property-name-form, which just like kebab-case,
* but if the first word is in "webkit", "moz", "ms", "o", it will use one dash as the prefix.
*/
get cssProp(): string;
/**
* Convert to dot.case.
*/
get dot(): string;
/**
* Convert to *nix path/case.
*/
get path(): string;
/**
* Convert to DOS path\\alt\\case.
*/
get pathAlt(): string;
/**
* Convert to Train-Case.
*/
get train(): string;
/**
* Convert to COBOL-CASE.
*/
get cobol(): string;
/**
* Convert to Pascal_Snake_Case.
*/
get pascalSnake(): string;
/**
* Convert to camel_Snake_Case.
*/
get camelSnake(): string;
/**
* Check if all letters in the string are uppercase (ignoring numbers, punctuation, etc.).
* @param str - String.
* @returns Are all letters uppercase?
*/
static areAllUpper(str: string): boolean;
toString(): string;
toJSON(): string;
}