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

Method FilterScan

script.go:566–574  ·  view source on GitHub ↗

FilterScan 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 an [io.Writer] to write its output to. See [Pipe.Filter] for concurrency handling.

(filter func(string, io.Writer))

Source from the content-addressed store, hash-verified

564// [io.Writer] to write its output to. See [Pipe.Filter] for concurrency
565// handling.
566func (p *Pipe) FilterScan(filter func(string, io.Writer)) *Pipe {
567 return p.Filter(func(r io.Reader, w io.Writer) error {
568 scanner := newScanner(r)
569 for scanner.Scan() {
570 filter(scanner.Text(), w)
571 }
572 return scanner.Err()
573 })
574}
575
576// First produces only the first n lines of the pipe's contents, or all the
577// lines if there are less than n. If n is zero or negative, there is no output

Callers 13

ColumnMethod · 0.95
ConcatMethod · 0.95
CountLinesMethod · 0.95
FilterLineMethod · 0.95
HashSumsMethod · 0.95
MatchMethod · 0.95
MatchRegexpMethod · 0.95
RejectMethod · 0.95
RejectRegexpMethod · 0.95
SliceMethod · 0.95

Calls 2

FilterMethod · 0.95
newScannerFunction · 0.85