UNPKG

naming-conventions-modeler

Version:
155 lines (154 loc) 4.88 kB
import { NamingConvention } from './modeler'; /** * `Convention` is an object with a `to` function that takes a string and returns a string, and an `is` * function that takes a string and returns a boolean. * * @property to - A function that takes a string and returns a string. * @property is - A function that takes a string and returns a boolean. */ export type Convention = { to: (str: string) => string; is: (str: string) => boolean; }; /** * It takes a naming convention and returns an object with two functions: `to` and `is` * * @param {NamingConvention} name - NamingConvention * * @returns An object with two properties: to and is. */ export declare function convention(name: NamingConvention): Convention; /** * It replaces all capital letters with a space and the capital letter, replaces all capital letter * sequences with a space and the capital letter sequence, replaces all spaces, underscores, and * hyphens with a space, converts the string to lowercase, and trims the string * * @param {string} str - The string to convert. * * @returns A string with no case. */ export declare function toNoCase(str: string): string; /** * If the string is already in no case, return true, otherwise return false. * * @param {string} str - The string to check. * * @returns A boolean value. */ export declare function isNoCase(str: string): boolean; /** * It converts a string to snake case by converting it to no case and replacing all spaces with * underscores * * @param {string} str - The string to convert. * * @returns A function that takes a string and returns a string with all the spaces replaced with * underscores. */ export declare function toSnakeCase(str: string): string; /** * If the string is already in snake case, then return true. * * @param {string} str - The string to check. * * @returns A boolean value. */ export declare function isSnakeCase(str: string): boolean; /** * Replace all non-word characters with a space, then replace all spaces with nothing, then replace all * lowercase letters that follow a non-word character with an uppercase letter, then replace all spaces * with nothing. * * @param {string} str - The string to convert. * * @returns A string with the first letter capitalized. */ export declare function toCamelCase(str: string): string; /** * If the string is already camelCase, then return true, otherwise return false. * * @param {string} str - The string to check. * * @returns A boolean value. */ export declare function isCamelCase(str: string): boolean; /** * Convert a string to pascal case. * * @param {string} str - The string to convert to PascalCase. * * @returns A string with the first letter capitalized. */ export declare function toPascalCase(str: string): string; /** * It returns true if the string is already in PascalCase * * @param {string} str - The string to check. * * @returns A boolean value. */ export declare function isPascalCase(str: string): boolean; /** * It converts a string to a macro case string * * @param {string} str - The string to convert. * * @returns A string with all lowercase letters and spaces replaced with underscores. */ export declare function toMacroCase(str: string): string; /** * Convert a string to MacroCase, and return true if the result is the same as the input. * * @param {string} str - The string to convert to MacroCase. * * @returns A boolean value. */ export declare function isMacroCase(str: string): boolean; /** * It takes a string, converts it to no case, and replaces all spaces with dashes * * @param {string} str - The string to convert. * * @returns A function that takes a string and returns a string. */ export declare function toKebabCase(str: string): string; /** * It returns true if the input string is already in kebab case * * @param {string} str - The string to check. * * @returns true */ export declare function isKebabCase(str: string): boolean; /** * It takes a string, converts it to train case * * @param {string} str - The string to convert. * * @returns A function that takes a string and returns a string. */ export declare function toTrainCase(str: string): string; /** * It returns true if the input string is already in train case * * @param {string} str - The string to check. * * @returns true */ export declare function isTrainCase(str: string): boolean; /** * It takes a string, converts it to flat case, and replaces all spaces with nothing * * @param {string} str - The string to convert. * * @returns A function that takes a string and returns a string. */ export declare function toFlatCase(str: string): string; /** * It returns true if the input string is already in flat case * * @param {string} str - The string to check. * * @returns true */ export declare function isFlatCase(str: string): boolean;