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

Method Join

script.go:698–713  ·  view source on GitHub ↗

Join joins all the lines in the pipe's contents into a single space-separated string, which will always end with a newline.

()

Source from the content-addressed store, hash-verified

696// Join joins all the lines in the pipe's contents into a single
697// space-separated string, which will always end with a newline.
698func (p *Pipe) Join() *Pipe {
699 return p.Filter(func(r io.Reader, w io.Writer) error {
700 scanner := newScanner(r)
701 first := true
702 for scanner.Scan() {
703 if !first {
704 fmt.Fprint(w, " ")
705 }
706 line := scanner.Text()
707 fmt.Fprint(w, line)
708 first = false
709 }
710 fmt.Fprintln(w)
711 return scanner.Err()
712 })
713}
714
715// JQ executes query on the pipe's contents (presumed to be valid JSON or
716// [JSONLines] data), applying the query to each newline-delimited input value

Callers 9

FindFilesFunction · 0.80
ListFilesFunction · 0.80
SliceFunction · 0.80
TestJoinHandlesLongLinesFunction · 0.80
ExamplePipe_FreqFunction · 0.80
ExamplePipe_JoinFunction · 0.80

Calls 2

FilterMethod · 0.95
newScannerFunction · 0.85