UNPKG

2.71 kBTypeScriptView Raw
1/**
2 * Truncates given string to the maximum characters count
3 *
4 * @param str An object that contains serializable values
5 * @param max Maximum number of characters in truncated string (0 = unlimited)
6 * @returns string Encoded
7 */
8export declare function truncate(str: string, max?: number): string;
9/**
10 * This is basically just `trim_line` from
11 * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67
12 *
13 * @param str An object that contains serializable values
14 * @param max Maximum number of characters in truncated string
15 * @returns string Encoded
16 */
17export declare function snipLine(line: string, colno: number): string;
18/**
19 * Join values in array
20 * @param input array of values to be joined together
21 * @param delimiter string to be placed in-between values
22 * @returns Joined values
23 */
24export declare function safeJoin(input: any[], delimiter?: string): string;
25/**
26 * Checks if the given value matches a regex or string
27 *
28 * @param value The string to test
29 * @param pattern Either a regex or a string against which `value` will be matched
30 * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match
31 * `pattern` if it contains `pattern`. Only applies to string-type patterns.
32 */
33export declare function isMatchingPattern(value: string, pattern: RegExp | string, requireExactStringMatch?: boolean): boolean;
34/**
35 * Test the given string against an array of strings and regexes. By default, string matching is done on a
36 * substring-inclusion basis rather than a strict equality basis
37 *
38 * @param testString The string to test
39 * @param patterns The patterns against which to test the string
40 * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to
41 * count. If false, `testString` will match a string pattern if it contains that pattern.
42 * @returns
43 */
44export declare function stringMatchesSomePattern(testString: string, patterns?: Array<string | RegExp>, requireExactStringMatch?: boolean): boolean;
45/**
46 * Given a string, escape characters which have meaning in the regex grammar, such that the result is safe to feed to
47 * `new RegExp()`.
48 *
49 * Based on https://github.com/sindresorhus/escape-string-regexp. Vendored to a) reduce the size by skipping the runtime
50 * type-checking, and b) ensure it gets down-compiled for old versions of Node (the published package only supports Node
51 * 12+).
52 *
53 * @param regexString The string to escape
54 * @returns An version of the string with all special regex characters escaped
55 */
56export declare function escapeStringForRegex(regexString: string): string;
57//# sourceMappingURL=string.d.ts.map
\No newline at end of file