MCPcopy
hub / github.com/bitfield/script / FilterLine

Method FilterLine

script.go:556–560  ·  view source on GitHub ↗

FilterLine sends the contents of the pipe to the function filter, a line at a time, and produces the result. filter takes each line as a string and returns a string as its output. See [Pipe.Filter] for concurrency handling.

(filter func(string) string)

Source from the content-addressed store, hash-verified

554// a time, and produces the result. filter takes each line as a string and
555// returns a string as its output. See [Pipe.Filter] for concurrency handling.
556func (p *Pipe) FilterLine(filter func(string) string) *Pipe {
557 return p.FilterScan(func(line string, w io.Writer) {
558 fmt.Fprintln(w, filter(line))
559 })
560}
561
562// FilterScan sends the contents of the pipe to the function filter, a line at
563// a time, and produces the result. filter takes each line as a string and an

Callers 8

BasenameMethod · 0.95
DirnameMethod · 0.95
ReplaceMethod · 0.95
ReplaceRegexpMethod · 0.95

Calls 1

FilterScanMethod · 0.95