peberminta - v0.10.0
    Preparing search index...

    Function filter

    • Make a new parser that keeps a match from a given parser only if a predicate passes; otherwise discards it (returns a NonMatch).

      This overload uses a type guard predicate to narrow the value type on success.

      Use satisfy to test a token at the current position instead of a value matched by another parser.

      Use takeWhile to accumulate 0 or more matches while predicate holds.

      mapR can be used if you need to filter and transform matches at the same time. But it is better to use filter and map instead in most cases.

      Type Parameters

      • TToken
      • TOptions
      • TValue1
      • TValue2

      Parameters

      • p: Parser<TToken, TOptions, TValue1>

        A base parser.

      • test: (
            value: TValue1,
            data: Data<TToken, TOptions>,
            i: number,
            j: number,
        ) => value is TValue2

        A type-guard predicate applied to the matched value to decide whether to keep it.

          • (
                value: TValue1,
                data: Data<TToken, TOptions>,
                i: number,
                j: number,
            ): value is TValue2
          • Parameters

            • value: TValue1

              Value matched by the base parser.

            • data: Data<TToken, TOptions>

              Data object (tokens and options).

            • i: number

              Parser position before the base parser matched.

            • j: number

              Parser position after the base parser matched.

            Returns value is TValue2

      Returns Parser<TToken, TOptions, TValue2>

    • Make a new parser that keeps a match from a given parser only if a predicate passes; otherwise discards it (returns a NonMatch).

      Use satisfy to test a token at the current position instead of a value matched by another parser.

      Use takeWhile to accumulate 0 or more matches while predicate holds.

      mapR can be used if you need to filter and transform matches at the same time. But it is better to use filter and map instead in most cases.

      Type Parameters

      • TToken
      • TOptions
      • TValue

      Parameters

      • p: Parser<TToken, TOptions, TValue>

        A base parser.

      • test: (value: TValue, data: Data<TToken, TOptions>, i: number, j: number) => boolean

        A predicate applied to the matched value to decide whether to keep it.

          • (value: TValue, data: Data<TToken, TOptions>, i: number, j: number): boolean
          • Parameters

            • value: TValue

              Value matched by the base parser.

            • data: Data<TToken, TOptions>

              Data object (tokens and options).

            • i: number

              Parser position before the base parser matched.

            • j: number

              Parser position after the base parser matched.

            Returns boolean

      Returns Parser<TToken, TOptions, TValue>