UNPKG

@typespec/http-server-js

Version:

TypeSpec HTTP server code generator for JavaScript

94 lines 2.97 kB
/** * Returns true if a name cannot be spoken. A name is unspeakable if: * * - It contains only separators and whitespace. * * OR * * - The first non-separator, non-whitespace character is a digit. * * @param name - a name in any case * @returns true if the name is unspeakable */ export declare function isUnspeakable(name: string): boolean; /** * Returns the property name to be used in an object literal. */ export declare function objectLiteralProperty(name: string): string; /** * Returns an access expression for a given subject and key. * * If the access can be performed using dot notation, it will. Otherwise, bracket notation will be used. * * @param subject - the expression to access * @param key - the key to access within the subject, must be an index value literal, not an expression */ export declare function access(subject: string, key: string | number): string; /** * Destructures a name into its components. * * The following case conventions are supported: * - PascalCase (["pascal", "case"]) * - camelCase (["camel", "case"]) * - snake_case (["snake", "case"]) * - kebab-case (["kebab", "case"]) * - dot.separated (["dot", "separated"]) * - path/separated (["path", "separated"]) * - double::colon::separated (["double", "colon", "separated"]) * - space separated (["space", "separated"]) * * - AND any combination of the above, or any other separators or combination of separators. * * @param name - a name in any case */ export declare function parseCase(name: string): ReCase; /** * An object allowing a name to be converted into various case conventions. */ export interface ReCase extends ReCaseUpper { /** * The components of the name with the first letter of each component capitalized and joined by an empty string. */ readonly pascalCase: string; /** * The components of the name with the first letter of the second and all subsequent components capitalized and joined * by an empty string. */ readonly camelCase: string; /** * Convert the components of the name into all uppercase letters. */ readonly upper: ReCaseUpper; } interface ReCaseUpper { /** * The components of the name. */ readonly components: readonly string[]; /** * The components of the name joined by underscores. */ readonly snakeCase: string; /** * The components of the name joined by hyphens. */ readonly kebabCase: string; /** * The components of the name joined by periods. */ readonly dotCase: string; /** * The components of the name joined by slashes. * * This uses forward slashes in the unix convention. */ readonly pathCase: string; /** * Join the components with any given string. * * @param separator - the separator to join the components with */ join(separator: string): string; } export {}; //# sourceMappingURL=case.d.ts.map