bufr/utils.go

34 lines
558 B
Go
Raw Normal View History

2022-04-19 14:35:10 +02:00
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)
}
2023-01-20 23:59:36 +01:00
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
}