parseListOf<T, R> function

List<R>? parseListOf<T, R>(
  1. Object? s,
  2. ParserFunction<T, R> parser, [
  3. List<R>? def
])

Parses s to a List<R>, where R is the result of parse.

def The default value if s is invalid.

Implementation

List<R>? parseListOf<T, R>(Object? s, ParserFunction<T, R> parser,
    [List<R>? def]) {
  if (s == null) return def;
  if (s is List) return s.map((e) => parser(e)).toList();
  return [parser(s as T)];
}