1 | /**
|
2 | * Functions that manipulate strings
|
3 | *
|
4 | * Although these functions are exported, they are subject to change without notice.
|
5 | *
|
6 | * @packageDocumentation
|
7 | */
|
8 | import { IInjectable } from './common';
|
9 | /**
|
10 | * Returns a string shortened to a maximum length
|
11 | *
|
12 | * If the string is already less than the `max` length, return the string.
|
13 | * Else return the string, shortened to `max - 3` and append three dots ("...").
|
14 | *
|
15 | * @param max the maximum length of the string to return
|
16 | * @param str the input string
|
17 | */
|
18 | export declare function maxLength(max: number, str: string): string;
|
19 | /**
|
20 | * Returns a string, with spaces added to the end, up to a desired str length
|
21 | *
|
22 | * If the string is already longer than the desired length, return the string.
|
23 | * Else returns the string, with extra spaces on the end, such that it reaches `length` characters.
|
24 | *
|
25 | * @param length the desired length of the string to return
|
26 | * @param str the input string
|
27 | */
|
28 | export declare function padString(length: number, str: string): string;
|
29 | export declare function kebobString(camelCase: string): string;
|
30 | export declare function functionToString(fn: Function): any;
|
31 | export declare function fnToString(fn: IInjectable): any;
|
32 | export declare function stringify(o: any): string;
|
33 | /** Returns a function that splits a string on a character or substring */
|
34 | export declare const beforeAfterSubstr: (char: string) => (str: string) => string[];
|
35 | export declare const hostRegex: RegExp;
|
36 | export declare const stripLastPathElement: (str: string) => string;
|
37 | export declare const splitHash: (str: string) => string[];
|
38 | export declare const splitQuery: (str: string) => string[];
|
39 | export declare const splitEqual: (str: string) => string[];
|
40 | export declare const trimHashVal: (str: string) => string;
|
41 | /**
|
42 | * Splits on a delimiter, but returns the delimiters in the array
|
43 | *
|
44 | * #### Example:
|
45 | * ```js
|
46 | * var splitOnSlashes = splitOnDelim('/');
|
47 | * splitOnSlashes("/foo"); // ["/", "foo"]
|
48 | * splitOnSlashes("/foo/"); // ["/", "foo", "/"]
|
49 | * ```
|
50 | */
|
51 | export declare function splitOnDelim(delim: string): (str: string) => string[];
|
52 | /**
|
53 | * Reduce fn that joins neighboring strings
|
54 | *
|
55 | * Given an array of strings, returns a new array
|
56 | * where all neighboring strings have been joined.
|
57 | *
|
58 | * #### Example:
|
59 | * ```js
|
60 | * let arr = ["foo", "bar", 1, "baz", "", "qux" ];
|
61 | * arr.reduce(joinNeighborsR, []) // ["foobar", 1, "bazqux" ]
|
62 | * ```
|
63 | */
|
64 | export declare function joinNeighborsR(acc: any[], x: any): any[];
|