UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

52 lines (51 loc) 2.14 kB
/** * Converts the first character of string to upper case and the remaining to lower case. * Returns a type-safe capitalized string. */ export declare function _capitalize(s?: string): Capitalize<string>; /** * Convert a string to a type-safe uppercase string. */ export declare function _toUpperCase(s: string): Uppercase<string>; /** * Convert a string to a type-safe lowercase string. */ export declare function _toLowercase(s: string): Lowercase<string>; export declare function _upperFirst(s?: string): Capitalize<string>; export declare function _lowerFirst(s: string): Uncapitalize<string>; /** * Like String.split(), but with limit, returning the tail together with last element. * * @returns Returns the new array of string segments. */ export declare function _split(str: string, separator: string, limit: number): string[]; export declare function _removeWhitespace(s: string): string; /** * _.truncate('hi-diddly-ho there, neighborino') * // => 'hi-diddly-ho there, neighbo...' */ export declare function _truncate(s: string, maxLen: number, omission?: string): string; /** * _.truncateMiddle('abcdefghijklmnopqrstuvwxyz', 10) * // => 'abcd...xyz' */ export declare function _truncateMiddle(s: string, maxLen: number, omission?: string): string; export declare function _substringBefore(s: string, delimiter: string): string; export declare function _substringBeforeLast(s: string, delimiter: string): string; export declare function _substringAfter(s: string, delimiter: string): string; export declare function _substringAfterLast(s: string, delimiter: string): string; /** * Returns the substring between LAST `leftDelimiter` and then FIRST `rightDelimiter`. * * @example * * const s = '/Users/lalala/someFile.test.ts' * _substringBetweenLast(s, '/', '.') * // `someFile` */ export declare function _substringBetweenLast(s: string, leftDelimiter: string, rightDelimiter: string): string; /** * Converts `\n` (aka new-line) to `<br>`, to be presented in HTML. * Keeps `\n`, so if it's printed in non-HTML environment it still looks ok-ish. */ export declare function _nl2br(s: string): string;