3.0.2 • Published 6 months ago

@types/balanced-match v3.0.2

Weekly downloads
136,230
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/balanced-match

Summary

This package contains type definitions for balanced-match (https://github.com/juliangruber/balanced-match).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/balanced-match.

index.d.ts

// Type definitions for balanced-match 1.0
// Project: https://github.com/juliangruber/balanced-match
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

interface Output {
    /**
     * The index of the first match of a
     */
    start: number;
    /**
     * The index of the matching b
     */
    end: number;
    /**
     * The preamble, a and b not included
     */
    pre: string;
    /**
     * The match, a and b not included
     */
    body: string;
    /**
     * The postscript, a and b not included
     */
    post: string;
}

/**
 *
 * For the first non-nested matching pair of a and b in str, return an object with those keys:
 * start the index of the first match of
 * `end` the index of the matching b
 * `pre` the preamble, a and b not included
 * `body` the match, a and b not included
 * `post` the postscript, a and b not included
 * If there's no match, `undefined` will be returned.
 * If the `str` contains more a than b / there are unmatched pairs,
 * the first match that was closed will be used.
 * For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`
 */
declare function balanced(a: string | RegExp, b: string | RegExp, str: string): Output | void;

declare namespace balanced {
    /**
     * For the first non-nested matching pair of `a` and `b` in `str`,
     * return an array with indexes: `[ <a index>, <b index> ]`.
     */
    function range(a: string | RegExp, b: string | RegExp, str: string): Output | void;
}

export = balanced;

Additional Details

  • Last updated: Thu, 23 Dec 2021 23:34:18 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Piotr Błażejewicz.

3.0.2

6 months ago

3.0.1

7 months ago

3.0.0

7 months ago

1.0.4

8 months ago

1.0.3

10 months ago

1.0.2

2 years ago

1.0.1

4 years ago

1.0.0

5 years ago