-
Notifications
You must be signed in to change notification settings - Fork 1
/
hyperspaced.go
61 lines (50 loc) 路 1.75 KB
/
hyperspaced.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Package hyperspaced provides utilities to improve the aesthetics of your
// favourite phrases with automatic space insertion (ASI).
package hyperspaced
import (
"github.com/72636c/hyperspaced/internal/transform"
)
var (
// Spaced is an alias for One that is retained for backwards compatibility.
Spaced = One
// SpacedN is an alias for N that is retained for backwards compatibility.
SpacedN = N
)
// Lower inserts a space between each character in a string, and converts to
// lowercase.
func Lower(str string) string {
return LowerN(str, 1)
}
// LowerN inserts n spaces between each character in a string, and converts to
// lowercase.
func LowerN(str string, n int) string {
return transform.Chars(str, transform.Lowercase, transform.NewSpace(n))
}
// N inserts n spaces between each character in a string.
func N(str string, n int) string {
return transform.Chars(str, transform.NewSpace(n))
}
// One inserts a space between each character in a string.
func One(str string) string {
return N(str, 1)
}
// Sponge inserts a space between each character in a string, and alternates
// between lowercasing and uppercasing.
func Sponge(str string) string {
return SpongeN(str, 1)
}
// SpongeN inserts n spaces between each character in a string, and alternates
// between lowercasing and uppercasing.
func SpongeN(str string, n int) string {
return transform.Chars(str, transform.Spongecase, transform.NewSpace(n))
}
// Upper inserts a space between each character in a string, and converts to
// uppercase.
func Upper(str string) string {
return UpperN(str, 1)
}
// UpperN inserts n spaces between each character in a string, and converts to
// uppercase.
func UpperN(str string, n int) string {
return transform.Chars(str, transform.Uppercase, transform.NewSpace(n))
}