UNPKG

1.97 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/balanced-match`
3
4# Summary
5This package contains type definitions for balanced-match (https://github.com/juliangruber/balanced-match).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/balanced-match.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/balanced-match/index.d.ts)
10````ts
11export interface Output {
12 /**
13 * The index of the first match of a
14 */
15 start: number;
16 /**
17 * The index of the matching b
18 */
19 end: number;
20 /**
21 * The preamble, a and b not included
22 */
23 pre: string;
24 /**
25 * The match, a and b not included
26 */
27 body: string;
28 /**
29 * The postscript, a and b not included
30 */
31 post: string;
32}
33
34/**
35 * For the first non-nested matching pair of a and b in str, return an object with those keys:
36 * start the index of the first match of
37 * `end` the index of the matching b
38 * `pre` the preamble, a and b not included
39 * `body` the match, a and b not included
40 * `post` the postscript, a and b not included
41 * If there's no match, `undefined` will be returned.
42 * If the `str` contains more a than b / there are unmatched pairs,
43 * the first match that was closed will be used.
44 * For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`
45 */
46export default function balanced(a: string | RegExp, b: string | RegExp, str: string): Output | undefined;
47
48/**
49 * For the first non-nested matching pair of `a` and `b` in `str`,
50 * return an array with indexes: `[ <a index>, <b index> ]`.
51 */
52export function range(a: string | RegExp, b: string | RegExp, str: string): [number, number] | undefined;
53
54````
55
56### Additional Details
57 * Last updated: Mon, 06 Nov 2023 22:41:04 GMT
58 * Dependencies: none
59
60# Credits
61These definitions were written by [Piotr Błażejewicz](https://github.com/peterblazejewicz).
62
\No newline at end of file