Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkwork committed Nov 1, 2024
1 parent 35c2a07 commit d952c44
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion stream/safeStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"
"sync"
"time"
"unicode"
"unicode/utf8"

"github.com/dc0d/caseconv"
Expand Down Expand Up @@ -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)))
}
Expand Down

0 comments on commit d952c44

Please sign in to comment.