flooent
Version:
Fluent interface to provide an expressive syntax for common manipulations.
77 lines (76 loc) • 2.86 kB
TypeScript
/**
* Returns the remaining text after the first occurrence of the given value.
* If the value does not exist in the string, the entire string is returned unchanged.
*/
export declare function after<T extends String>(value: T, part: string): T;
/**
* Returns the remaining text after the last occurrence of the given value.
* If the value does not exist in the string, the entire string is returned unchanged.
*/
export declare function afterLast<T extends String>(value: T, part: string): T;
/**
* Returns the text before the first occurrence of the given value.
* If the value does not exist in the string, the entire string is returned unchanged.
*/
export declare function before<T extends String>(value: T, part: string): T;
/**
* Returns the text before the last occurrence of the given value.
* If the value does not exist in the string, the entire string is returned unchanged.
*/
export declare function beforeLast<T extends String>(value: T, part: string): T;
/**
* Wraps a string with the given value.
*/
export declare function wrap(value: string, start: string, end?: string): string;
/**
* Unwraps a string with the given value.
*/
export declare function unwrap<T extends String>(value: T, start: string, end?: string): T;
/**
* Alias for `concat`. Appends the given value to string.
*/
export declare function append<T extends String>(value: T, part: string): T;
/**
* Prepends the given value to string.
*/
export declare function prepend(value: string, part: string): string;
/**
* Appends the given value only if string doesn't already end with it.
*/
export declare function endWith<T extends String>(value: T, part: string): T;
/**
* Prepends the given value only if string doesn't already start with it.
*/
export declare function startWith<T extends String>(value: T, part: string): string;
/**
* Truncates text to given length and appends second argument if string got truncated.
*/
export declare function limit<T extends String>(value: T, n: number, append?: string): T;
/**
* Turns the string into title case.
*/
export declare function title<T extends String>(value: T): string;
/**
* Turns the string into kebab case.
*/
export declare function kebab<T extends String>(value: T): string;
/**
* Turns the string into snake case.
*/
export declare function snake<T extends String>(value: T, replacement?: string): string;
/**
* Turns the string into studly case.
*/
export declare function studly<T extends String>(value: T): string;
/**
* Turns the string into camel case.
*/
export declare function camel<T extends String>(value: T): string;
/**
* Capitalizes the first character.
*/
export declare function capitalize<T extends String>(value: T): string;
/**
* Turns the string into URI conform slug.
*/
export declare function slug<T extends String>(value: T, replacement?: string): string;