• Version 3.0.4
  • Published
  • 6.39 kB
  • No dependencies
  • MIT license


npm i @types/braces
yarn add @types/braces
pnpm add @types/braces


TypeScript definitions for braces



variable braces

const braces: Braces;


    interface Options

    interface Options {}

      property expand

      expand?: boolean | undefined;
      • Generate an "expanded" brace pattern (alternatively you can use the braces.expand() method).


        Example 1

        console.log(braces('a/{b,c}/d', { expand: true })); //=> [ 'a/b/d', 'a/c/d' ]

      property keepEscaping

      keepEscaping?: boolean | undefined;
      • Do not strip backslashes that were used for escaping from the result.


      property maxLength

      maxLength?: number | undefined;
      • Limit the length of the input string. Useful when the input string is generated or your application allows users to pass a string, et cetera.


        Example 1

        console.log(braces('a/{b,c}/d', { maxLength: 3 })); //=> throws an error

      property nodupes

      nodupes?: boolean | undefined;
      • Remove duplicates from the returned array.


      property quantifiers

      quantifiers?: boolean | undefined;
      • In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, a{1,3} will match the letter a one to three times.

        Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists)

        The quantifiers option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) are defined in the given pattern, and not to try to expand them as lists.


        Example 1

        const braces = require('braces'); console.log(braces('a/b{1,3}/{x,y,z}')); //=> [ 'a/b(1|3)/(x|y|z)' ] console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true})); //=> [ 'a/b{1,3}/(x|y|z)' ] console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true, expand: true})); //=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ]

      property rangeLimit

      rangeLimit?: number | undefined;
      • To prevent malicious patterns from being passed by users, an error is thrown when braces.expand() is used or options.expand is true and the generated range will exceed the rangeLimit.

        You can customize options.rangeLimit or set it to Infinity to disable this altogether.


        Example 1

        // pattern exceeds the "rangeLimit", so it's optimized automatically console.log(braces.expand('{1..1000}')); //=> ['([1-9]|[1-9][0-9]{1,2}|1000)']

        // pattern does not exceed "rangeLimit", so it's NOT optimized console.log(braces.expand('{1..100}')); //=> ['1', '2', '3', '4', '5', …, '100']

      property transform

      transform?: Transform | undefined;
      • Customize range expansion.


        Example 1

        const range = braces.expand('x{a..e}y', { transform: (str) => foo/${str} });

        console.log(range); //=> [ 'xfooay', 'xfooby', 'xfoocy', 'xfoody', 'xfooey' ]

      Type Aliases

      type Transform

      type Transform = (str: string) => string;

        Package Files (1)

        Dependencies (0)

        No dependencies.

        Dev Dependencies (0)

        No dev dependencies.

        Peer Dependencies (0)

        No peer dependencies.


        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/braces.

        • Markdown
        • HTML
          <a href="https://www.jsdocs.io/package/@types/braces"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>