regjsparser

  • Version 0.12.0
  • Published
  • 73.5 kB
  • 1 dependency
  • BSD-2-Clause license

Install

npm i regjsparser
yarn add regjsparser
pnpm add regjsparser

Overview

Parsing the JavaScript's RegExp in JavaScript.

Index

Functions

function parse

parse: <F extends Features = {}>(
str: string,
flags: string,
features?: F
) => RootNode<F>;

    Type Aliases

    type Alternative

    type Alternative<F extends Features = {}> = Base<'alternative'> & {
    body: RootNode<F>[];
    };

      type Anchor

      type Anchor = Base<'anchor'> & {
      kind: 'boundary' | 'end' | 'not-boundary' | 'start';
      };

        type AstNode

        type AstNode<F extends Features = {}> =
        | Alternative<F>
        | Anchor
        | CharacterClass<F>
        | CharacterClassEscape
        | CharacterClassRange
        | Disjunction<F>
        | Dot
        | Group<F>
        | Quantifier<F>
        | Reference<F>
        | _If<F['unicodePropertyEscape'], UnicodePropertyEscape, never>
        | Value;

          type AstNodeType

          type AstNodeType =
          | 'alternative'
          | 'anchor'
          | 'characterClass'
          | 'characterClassEscape'
          | 'characterClassRange'
          | 'disjunction'
          | 'dot'
          | 'group'
          | 'quantifier'
          | 'reference'
          | 'unicodePropertyEscape'
          | 'value';

            type Base

            type Base<T extends AstNodeType> = {
            range: [number, number];
            raw: string;
            type: T;
            };

              type CapturingGroup

              type CapturingGroup<F extends Features = {}> = Base<'group'> & {
              behavior: 'normal';
              body: RootNode<F>[];
              } & _If<
              F['namedGroups'],
              {
              name?: Identifier;
              },
              {
              name: undefined;
              }
              >;

                type CharacterClass

                type CharacterClass<F extends Features = {}> = Base<'characterClass'> & {
                body: CharacterClassBody[];
                negative: boolean;
                kind: 'union' | _If<F['unicodeSet'], 'intersection' | 'subtraction', never>;
                };

                  type CharacterClassBody

                  type CharacterClassBody =
                  | CharacterClassEscape
                  | CharacterClassRange
                  | UnicodePropertyEscape
                  | Value;

                    type CharacterClassEscape

                    type CharacterClassEscape = Base<'characterClassEscape'> & {
                    value: 'd' | 'D' | 'w' | 'W' | 's' | 'S';
                    };

                      type CharacterClassRange

                      type CharacterClassRange = Base<'characterClassRange'> & {
                      max: Value;
                      min: Value;
                      };

                        type Disjunction

                        type Disjunction<F extends Features = {}> = Base<'disjunction'> & {
                        body: [RootNode<F>, RootNode<F>, ...RootNode<F>[]];
                        };

                          type Dot

                          type Dot = Base<'dot'>;

                            type Features

                            type Features = {
                            lookbehind?: boolean;
                            namedGroups?: boolean;
                            unicodePropertyEscape?: boolean;
                            unicodeSet?: boolean;
                            modifiers?: boolean;
                            };

                              type Group

                              type Group<F extends Features = {}> = CapturingGroup<F> | NonCapturingGroup<F>;

                                type Identifier

                                type Identifier = Base<'value'> & {
                                value: string;
                                };

                                  type IndexReference

                                  type IndexReference = Base<'reference'> & {
                                  matchIndex: number;
                                  name: undefined;
                                  };

                                    type ModifierFlags

                                    type ModifierFlags = {
                                    enabling: string;
                                    disabling: string;
                                    };

                                      type NamedReference

                                      type NamedReference = Base<'reference'> & {
                                      matchIndex: undefined;
                                      name: Identifier;
                                      };

                                        type NonCapturingGroup

                                        type NonCapturingGroup<F extends Features = {}> = Base<'group'> &
                                        (
                                        | {
                                        behavior:
                                        | 'lookahead'
                                        | 'lookbehind'
                                        | 'negativeLookahead'
                                        | 'negativeLookbehind';
                                        body: RootNode<F>[];
                                        }
                                        | ({
                                        behavior: 'ignore';
                                        body: RootNode<F>[];
                                        } & _If<
                                        F['modifiers'],
                                        {
                                        modifierFlags?: ModifierFlags;
                                        },
                                        {
                                        modifierFlags: undefined;
                                        }
                                        >)
                                        );

                                          type Quantifier

                                          type Quantifier<F extends Features = {}> = Base<'quantifier'> & {
                                          body: [RootNode<F>];
                                          greedy: boolean;
                                          max?: number;
                                          min: number;
                                          symbol?: '?' | '*' | '+';
                                          };

                                            type Reference

                                            type Reference<F extends Features = {}> = _If<
                                            F['namedGroups'],
                                            IndexReference | NamedReference,
                                            IndexReference
                                            >;

                                              type RootNode

                                              type RootNode<F extends Features = {}> = Exclude<AstNode<F>, CharacterClassRange>;

                                                type UnicodePropertyEscape

                                                type UnicodePropertyEscape = Base<'unicodePropertyEscape'> & {
                                                negative: boolean;
                                                value: string;
                                                };

                                                  type Value

                                                  type Value = Base<'value'> & {
                                                  codePoint: number;
                                                  kind:
                                                  | 'controlLetter'
                                                  | 'hexadecimalEscape'
                                                  | 'identifier'
                                                  | 'null'
                                                  | 'octal'
                                                  | 'singleEscape'
                                                  | 'symbol'
                                                  | 'unicodeCodePointEscape'
                                                  | 'unicodeEscape';
                                                  };

                                                    Package Files (1)

                                                    Dependencies (1)

                                                    Dev Dependencies (9)

                                                    Peer Dependencies (0)

                                                    No peer dependencies.

                                                    Badge

                                                    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/regjsparser.

                                                    • Markdown
                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/regjsparser)
                                                    • HTML
                                                      <a href="https://www.jsdocs.io/package/regjsparser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>