Completed unit tests and added README and LICENSE
This commit is contained in:
parent
1651987399
commit
f11008ab45
6 changed files with 96 additions and 8 deletions
22
scriptx.go
22
scriptx.go
|
|
@ -1,22 +0,0 @@
|
|||
package scriptx
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ToJSON(fn func(line string) any) func(r io.Reader, w io.Writer) error {
|
||||
return func(r io.Reader, w io.Writer) error {
|
||||
return eachLine(r, func(line string) (err error) {
|
||||
jsonBytes, err := json.Marshal(fn(line))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = w.Write(jsonBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = w.Write([]byte{'\n'})
|
||||
return err
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue