ret-extended
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

ret-extended

GitHub license npm version build Dependabot semantic-release

Overview

This adds details to the tokens produced by the ret package. Namely it adds the following properties.

For all tokens the following properties are given:

/**
 * Details that are added to every ret.js token
 */
export interface Detailed<T extends Tokens> {
  /**
   * Minimum number of characters required to 'satisfy' the regex component
   */
  minChar: number;
  /**
   * Maximum number of characters required to 'satisfy' the regex component
   */
  maxChar: number;
  /**
   * Whether the '^' positional is applied or not;
   */
  leftEnd: boolean;
  /**
   * Whether the '$' positional is applied or not;
   */
  rightEnd: boolean;
  /**
   * The original tokens
   */
  token: T
  /**
   * Regular expression (Regex Object with flags) that the token is representing
   */
  regex: RegExp;
  /**
   * Generator for possible values of regular expression
   */
  pattern?: string[];
  /**
   * Whether this token has a 'fixed solution', e.g `(hello)`,
   * or many solutions, e.g. `[0-9]`.
   */
  fixed: boolean;
}

In addition, remembered capturing groups are given a reference entry which is the value that backreferences should use to refer to that group.

Usage

import { regexDetailTokenizer } from '../lib';

regexDetailTokenizer(/a-z/i) // Outputs detailed tokens

License

©2021–present Jesse Wright, MIT License.

Package Sidebar

Install

npm i ret-extended

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

19.7 kB

Total Files

11

Last publish

Collaborators

  • jeswr