bufr/utils.go
2023-01-20 23:59:36 +01:00

34 lines
558 B
Go

package bufr
import (
"bufio"
"io"
"strings"
)
func prependString(str string, r io.Reader) *bufio.Reader {
return bufio.NewReader(io.MultiReader(strings.NewReader(str), r))
}
func prependRune(rn rune, r io.Reader) *bufio.Reader {
return prependString(string(rn), r)
}
func findFirstTrue(rn rune, functions []RuneFunc) bool {
for _, f := range functions {
if f(rn) {
return true
}
}
return false
}
func findFirstFalse(rn rune, functions []RuneFunc) bool {
for _, f := range functions {
if !f(rn) {
return false
}
}
return true
}