UNPKG

@thi.ng/strings

Version:

Various string formatting & utility functions

106 lines 2.23 kB
import type { FnS, Stringer } from "./api.js"; /** * Uppercase string formatter. * * @param x - string to transform */ export declare const upper: FnS; /** * Lowercase string formatter. * * @param x - string to transform */ export declare const lower: FnS; /** * String formatter which capitalizes first character. * * @param x - string to transform */ export declare const capitalize: FnS; /** * Converts a CamelCase string into kebab case, with optional custom * delimiter (`-` by default). * * @remarks * See {@link snake} for alternative. * * @example * ```ts tangle:../export/kebab.ts * import { kebab } from "@thi.ng/strings"; * * console.log(kebab("FooBar23Baz")); * // "foo-bar23-baz" * ``` * * @param x - * @param delim - */ export declare const kebab: Stringer<string>; /** * Short for {@link kebab} using `_` as delimiter. * * @remarks * Also see {@link upperSnake} for alternative. * * @example * ```ts tangle:../export/snake.ts * import { snake } from "@thi.ng/strings"; * * console.log(snake("FooBar23Baz")); * // "foo_bar23_baz" * ``` * * @param x - */ export declare const snake: FnS; /** * Uppercase version of {@link snake}. * * @remarks * Also see {@link snake} for alternative. * * @param x - */ export declare const upperSnake: FnS; /** * Converts a kebab-case or snake_case string into camelCase. Uses `-` as * default delimiter. * * @remarks * Alse see {@link pascal} for alternative. * * @example * ```ts tangle:../export/camel.ts * import { camel } from "@thi.ng/strings"; * * console.log(camel("foo-bar23-baz")); * // fooBar23Baz * * console.log(camel("FOO_BAR23_BAZ", "_")); * // fooBar23Baz * ``` * * @param x - * @param delim - */ export declare const camel: Stringer<string>; /** * Converts a kebab-case or snake_case string into PascalCase. Uses `-` as * default delimiter. * * @example * ```ts tangle:../export/pascal.ts * import { pascal } from "@thi.ng/strings"; * * console.log(pascal("foo-bar23-baz")); * // FooBar23Baz * * console.log(pascal("FOO_BAR23_BAZ", "_")); * // FooBar23Baz * ``` * * @param x * @param delim */ export declare const pascal: Stringer<string>; //# sourceMappingURL=case.d.ts.map