diff --git a/stream/safeStream.go b/stream/safeStream.go index 443451b5..b8c8f9a2 100644 --- a/stream/safeStream.go +++ b/stream/safeStream.go @@ -25,6 +25,7 @@ import ( "strings" "sync" "time" + "unicode" "unicode/utf8" "github.com/dc0d/caseconv" @@ -443,7 +444,22 @@ func (b *Buffer) InsertRune(index int, r rune) { n := utf8.EncodeRune(buffer[:], r) b.InsertBytes(index, buffer[:n]) } - +func isAllLetters(s string) bool { + for _, r := range s { + if !unicode.IsLetter(r) { + return false + } + } + return true +} +func (b *Buffer) Join(sep string, size int) string { + mylog.Check(!isAllLetters(b.String())) + result := "" + for block := range slices.Chunk(b.Bytes(), size) { + result += string(block) + sep + } + return strings.TrimSuffix(result, sep) +} func (b *Buffer) InsertString(index int, s string) string { return string(b.InsertBytes(index, []byte(s))) }