mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56fc2aabd6 | ||
|
|
0ddd52225b | ||
|
|
3919160e38 | ||
|
|
40ec5bc0f6 |
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by MIT license
|
||||
|
||||
// Package function implements some functions for control the function execution and some is for functional programming.
|
||||
|
||||
package function
|
||||
|
||||
import (
|
||||
@@ -36,10 +35,10 @@ func Before(n int, fn interface{}) func(args ...interface{}) []reflect.Value {
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
// Fn is for curry function which is func(...interface{}) interface{}
|
||||
type Fn func(...interface{}) interface{}
|
||||
|
||||
// Curry make a curryed function
|
||||
// Curry make a curry function
|
||||
func (f Fn) Curry(i interface{}) func(...interface{}) interface{} {
|
||||
return func(values ...interface{}) interface{} {
|
||||
v := append([]interface{}{i}, values...)
|
||||
|
||||
@@ -7,6 +7,7 @@ package strutil
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// CamelCase covert string to camelCase string.
|
||||
@@ -40,18 +41,16 @@ func Capitalize(s string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
res := ""
|
||||
for i, v := range []rune(s) {
|
||||
out := make([]rune, len(s))
|
||||
for i, v := range s {
|
||||
if i == 0 {
|
||||
if v >= 97 && v <= 122 {
|
||||
v -= 32
|
||||
}
|
||||
res += string(v)
|
||||
out[i] = unicode.ToUpper(v)
|
||||
} else {
|
||||
res += strings.ToLower(string(v))
|
||||
out[i] = unicode.ToLower(v)
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// LowerFirst converts the first character of string to lower case.
|
||||
|
||||
Reference in New Issue
Block a user