aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-04-30 03:38:16 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-04-30 03:38:16 +0200
commit3d61eac8c023a7f9509e0371baef40c00b0132f2 (patch)
tree4d2e739eec484e891376c78e2fa17c4e337f076c
parent0c7485486eaa62e8b7673949e09d546b78649ab8 (diff)
downloadrefcat-3d61eac8c023a7f9509e0371baef40c00b0132f2.tar.gz
refcat-3d61eac8c023a7f9509e0371baef40c00b0132f2.zip
update docs
-rw-r--r--skate/cmd/skate-map/main.go4
-rw-r--r--skate/map.go7
2 files changed, 6 insertions, 5 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go
index ee02875..2517878 100644
--- a/skate/cmd/skate-map/main.go
+++ b/skate/cmd/skate-map/main.go
@@ -21,8 +21,8 @@
// be skipped, if we limit number of splits)
// (3) we pass the data to jq, with a bit larger buffer (default is 1MB)
// (4) we want no "null" output
-// (5) tostring prints input as string, because we need to carry the document forward
-// (6) but we need some cleanup, too
+// (5) tostring prints the input as string, because we need to carry the document forward ...
+// (6) ... but we'll need some cleanup, too
// (7) we normalize the DOI to lowercase
// (8) a custom filter to normalize a DOI in a specific column
// (9) sorting by DOI
diff --git a/skate/map.go b/skate/map.go
index 094d3e2..1d6bc0b 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -42,11 +42,12 @@ type Mapper func([]byte) ([][]byte, error)
// AsTSV serializes the result of a field mapper as TSV. This is a slim
// adapter, e.g. to parallel.Processor, which expects this function signature.
-// If the last byte of the last field is not a newline, it will be appended.
+// A newline will be appended, if not there already.
func (f Mapper) AsTSV(p []byte) ([]byte, error) {
var (
fields [][]byte
err error
+ b []byte
)
if fields, err = f(p); err != nil {
return nil, err
@@ -54,14 +55,14 @@ func (f Mapper) AsTSV(p []byte) ([]byte, error) {
if len(fields) == 0 {
return nil, nil
}
- b := bytes.Join(fields, bTab)
+ b = bytes.Join(fields, bTab)
if len(b) > 0 && !bytes.HasSuffix(b, bNewline) {
b = append(b, bNewline...)
}
return b, nil
}
-// WithPrefix adds a given prefix to the first element.
+// WithPrefix is a "mapper middleware", adding a given prefix to the first field.
func WithPrefix(f Mapper, prefix string) Mapper {
return func(p []byte) ([][]byte, error) {
fields, err := f(p)