Function sideEffect

  • Defines a new TokenParser that will execute sideEffect with the ParseState passed to it and then return it.

    sideEffect is only executed and does not return anything. It is only executed for it's side-effects.

    Any side-effects executed may impose performance penalties to the parsing process, thus this functionality must be used with great care and only in non-critical paths.

    It can be used for logging support.

    Returns

    A new TokenParser that will execute sideEffect and not change the result.

    Type Parameters

    Parameters

    • sideEffect: ((state: ParseState<D, E>) => void)

      A callback that will be called to produce side effects based on the ParseState passed.

    Returns TokenParser<D, E>