text

package
v0.3.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuilderType = toy.NewType[*Builder]("text.Builder", func(_ *toy.Runtime, args ...toy.Value) (toy.Value, error) {
	if len(args) != 0 {
		return nil, &toy.WrongNumArgumentsError{Got: len(args)}
	}
	return new(Builder), nil
})
View Source
var Module = &toy.BuiltinModule{
	Name: "text",
	Members: map[string]toy.Value{
		"Builder": BuilderType,

		"contains":     toy.NewBuiltinFunction("text.contains", containsFn),
		"containsAny":  toy.NewBuiltinFunction("text.containsAny", fndef.ASSRB("s", "chars", strings.ContainsAny)),
		"hasPrefix":    toy.NewBuiltinFunction("text.hasPrefix", fndef.ASSRB("s", "prefix", strings.HasPrefix)),
		"hasSuffix":    toy.NewBuiltinFunction("text.hasSuffix", fndef.ASSRB("s", "suffix", strings.HasSuffix)),
		"trimLeft":     toy.NewBuiltinFunction("text.trimLeft", fndef.ASSRS("s", "cutset", strings.TrimLeft)),
		"trimRight":    toy.NewBuiltinFunction("text.trimRight", fndef.ASSRS("s", "cutset", strings.TrimRight)),
		"trimPrefix":   toy.NewBuiltinFunction("text.trimPrefix", fndef.ASSRS("s", "prefix", strings.TrimPrefix)),
		"trimSuffix":   toy.NewBuiltinFunction("text.trimSuffix", fndef.ASSRS("s", "suffix", strings.TrimSuffix)),
		"trimSpace":    toy.NewBuiltinFunction("text.trimSpace", fndef.ASRS("s", strings.TrimSpace)),
		"trim":         toy.NewBuiltinFunction("text.trim", fndef.ASSRS("s", "cutset", strings.Trim)),
		"toLower":      toy.NewBuiltinFunction("text.toLower", fndef.ASRS("s", strings.ToLower)),
		"toUpper":      toy.NewBuiltinFunction("text.toUpper", fndef.ASRS("s", strings.ToUpper)),
		"toTitle":      toy.NewBuiltinFunction("text.toTitle", toTitleFn),
		"join":         toy.NewBuiltinFunction("text.join", joinFn),
		"split":        toy.NewBuiltinFunction("text.split", splitFn),
		"splitAfter":   toy.NewBuiltinFunction("text.splitAfter", splitAfterFn),
		"fields":       toy.NewBuiltinFunction("text.fields", fndef.ASRSs("s", strings.Fields)),
		"replace":      toy.NewBuiltinFunction("text.replace", replaceFn),
		"cut":          toy.NewBuiltinFunction("text.cut", cutFn),
		"cutPrefix":    toy.NewBuiltinFunction("text.cutPrefix", fndef.ASSRSB("s", "prefix", strings.CutPrefix)),
		"cutSuffix":    toy.NewBuiltinFunction("text.cutSuffix", fndef.ASSRSB("s", "suffix", strings.CutSuffix)),
		"index":        toy.NewBuiltinFunction("text.index", indexFn),
		"indexAny":     toy.NewBuiltinFunction("text.indexAny", indexAnyFn),
		"lastIndex":    toy.NewBuiltinFunction("text.lastIndex", lastIndexFn),
		"lastIndexAny": toy.NewBuiltinFunction("text.lastIndexAny", lastIndexAnyFn),

		"quote":          toy.NewBuiltinFunction("text.quote", fndef.ASRS("s", strconv.Quote)),
		"quoteToASCII":   toy.NewBuiltinFunction("text.quoteToASCII", fndef.ASRS("s", strconv.QuoteToASCII)),
		"quoteToGraphic": toy.NewBuiltinFunction("text.quoteToGraphic", fndef.ASRS("s", strconv.QuoteToGraphic)),
		"unquote":        toy.NewBuiltinFunction("text.unquote", fndef.ASRSE("s", strconv.Unquote)),

		"parseInt":   toy.NewBuiltinFunction("text.parseInt", parseInt),
		"parseFloat": toy.NewBuiltinFunction("text.parseFloat", parseFloat),
		"parseBool":  toy.NewBuiltinFunction("text.parseBool", parseBool),
	},
}

Functions

This section is empty.

Types

type Builder

type Builder strings.Builder

func (*Builder) Clone

func (b *Builder) Clone() toy.Value

func (*Builder) Convert

func (b *Builder) Convert(p any) error

func (*Builder) IsFalsy

func (b *Builder) IsFalsy() bool

func (*Builder) Len

func (b *Builder) Len() int

func (*Builder) Property

func (b *Builder) Property(key toy.Value) (value toy.Value, found bool, err error)

func (*Builder) String

func (b *Builder) String() string

func (*Builder) Type

func (b *Builder) Type() toy.ValueType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL