Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tokenizer<Type, Stage, Context>

Type parameters

  • Type = unknown

    The type of the token emitted by the tokenizer.

  • Stage = void

    The tokenizer stage type.

  • Context = void

    The context passed to the tokenizer.

Hierarchy

  • Tokenizer

Callable

  • Reads tokens from the input in a non-streaming fashion.

    Parameters

    • input: string

      The input string to tokenize.

    • handler: TokenHandler<Type, Context>

      The callbacks that are invoked when tokens are read from the string.

    • context: Context

      The context that should be passed to readers and stage providers.

    • Optional state: TokenizerState<Stage>

      The mutable state used by the tokenizer.

    Returns TokenizerState<Stage>

    The result state of the tokenizer.

Index

Methods

Methods

  • Reads tokens from the chunk in a streaming fashion. During streaming, TokenHandler is triggered only with confirmed tokens. Token is confirmed if the consequent token was successfully read.

    let state = tokenizer.write('foo', handler);
    tokenizer.write('bar', handler, state);
    tokenizer.end(handler, state);

    Parameters

    • chunk: string

      The input chunk to tokenize.

    • handler: TokenHandler<Type, Context>

      The callbacks that are invoked when tokens are read from the string.

    • state: void | TokenizerState<Stage>

      The mutable state returned by the previous Tokenizer.write call.

    • context: Context

      The context that should be passed to readers and stage providers.

    Returns TokenizerState<Stage>

    The result state of the tokenizer.

Generated using TypeDoc