Script.mapLines constructor

Script.mapLines(
  1. String mapper(
    1. String line
    ), {
  2. String? name,
})

Creates a Script from a function that maps strings to strings.

This script passes each line of stdin to mapper and emits the result via stdout.

Implementation

factory Script.mapLines(String Function(String line) mapper,
        {String? name}) =>
    Script.fromLineTransformer(
        StreamTransformer.fromBind((stream) => stream.map(mapper)),
        name: name ?? mapper.toString());