public static IStreamable MapText(this IStreamable streamable, Encoding outputEncoding, Func <string, string> mapper) { if (streamable == null) { throw new ArgumentNullException(nameof(streamable)); } if (outputEncoding == null) { throw new ArgumentNullException(nameof(outputEncoding)); } if (mapper == null) { throw new ArgumentNullException(nameof(mapper)); } return(Streamable.Create(() => { var mapped = mapper(streamable.ReadText()); return new MemoryStream(outputEncoding.GetBytes(mapped)); })); }