map<S> method

  1. @useResult
Parser<S> map<S>(
  1. Callback<R, S> callback, {
  2. @Deprecated('All callbacks are considered to have side-effects') bool hasSideEffects = true,
})

Returns a parser that evaluates a callback as the production action on success of the receiver.

For example, the parser digit().map((char) => int.parse(char)) returns the number 1 for the input string '1'. If the delegate fails, the production action is not executed and the failure is passed on.

Implementation

@useResult
Parser<S> map<S>(
  Callback<R, S> callback, {
  @Deprecated('All callbacks are considered to have side-effects')
      bool hasSideEffects = true,
}) =>
    MapParser<R, S>(this, callback);