-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
str.go
39 lines (35 loc) · 1.08 KB
/
str.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
// Package str exposes functionality from Go's strings package as an Elvish
// module.
package str
import (
"strings"
"github.com/elves/elvish/eval"
)
var Ns = eval.NewNs().AddBuiltinFns("str:", fns)
var fns = map[string]interface{}{
"compare": strings.Compare,
"contains": strings.Contains,
"contains-any": strings.ContainsAny,
"count": strings.Count,
"equal-fold": strings.EqualFold,
// TODO: Fields, FieldsFunc
"has-prefix": strings.HasPrefix,
"has-suffix": strings.HasSuffix,
"index": strings.Index,
"index-any": strings.IndexAny,
// TODO: IndexFunc, Join
"last-index": strings.LastIndex,
// TODO: LastIndexFunc, Map, Repeat, Replace, Split, SplitAfter
"title": strings.Title,
"to-lower": strings.ToLower,
"to-title": strings.ToTitle,
"to-upper": strings.ToUpper,
// TODO: ToLowerSpecial, ToTitleSpecial, ToUpperSpecial
"trim": strings.Trim,
"trim-left": strings.TrimLeft,
"trim-right": strings.TrimRight,
// TODO: TrimLeft,Right}Func
"trim-space": strings.TrimSpace,
"trim-prefix": strings.TrimPrefix,
"trim-suffix": strings.TrimSuffix,
}