utils

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DirExists = Cached1In1Out(_DirExists)
View Source
var FileExists = Cached1In1Out(_FileExists)

Functions

func AppendFront added in v0.19.2

func AppendFront[T any](el T, arr []T) []T

func Bool2Int

func Bool2Int(b bool) int

func Cached1In1Out added in v0.17.4

func Cached1In1Out[I comparable, O any](f func(I) O) func(I) O

func Cached1In1OutErr added in v0.17.4

func Cached1In1OutErr[I comparable, O1 any](f func(I) (O1, error)) func(I) (O1, error)

func Cached1In2Out added in v0.17.7

func Cached1In2Out[I comparable, O1 any, O2 any](f func(I) (O1, O2)) func(I) (O1, O2)

func Cached1In2OutErr added in v0.17.4

func Cached1In2OutErr[I comparable, O1 any, O2 any](f func(I) (O1, O2, error)) func(I) (O1, O2, error)

func Cached2In1OutErr added in v0.17.4

func Cached2In1OutErr[I1 comparable, I2 comparable, O1 any](f func(I1, I2) (O1, error)) func(I1, I2) (O1, error)

func Clamp

func Clamp(min int, n, max int) int

func EndsWith

func EndsWith(string string, substrings []string) bool

func ExecuteWithTimeout added in v0.22.4

func ExecuteWithTimeout[T any](timeout time.Duration, f func() (T, error)) (T, error)

func GlobstarMatch added in v0.17.4

func GlobstarMatch(pattern string, check string) (bool, error)

func GoldenTest

func GoldenTest(t *testing.T, file string, content string)

func InArray

func InArray[T comparable](value T, array []T) bool

func ItoAArr added in v0.17.4

func ItoAArr(arr []int) string

func ItoAArr2 added in v0.17.4

func ItoAArr2(arr [2]int) string

func MakeCachedFindClosestDirWithRootFile added in v0.20.0

func MakeCachedFindClosestDirWithRootFile(rootFiles []string) func(string) *SourcesRoot

func Max added in v0.17.4

func Max[T any](arr []T, f func(T) int) int

func Merge

func Merge[T any](acc map[string]T, maps ...map[string]T) map[string]T

func PrefixN

func PrefixN(str string, char rune) int

func Scale added in v0.17.4

func Scale(n float64, lo float64, hi float64, tlo float64, thi float64) float64

func UnquoteSafe added in v0.17.4

func UnquoteSafe(types ...string) participle.Option

UnquoteSafe applies strconv.Unquote() to tokens of the given types.

Tokens of type "String" will be unquoted if no other types are provided.

Types

type CallStack added in v0.17.4

type CallStack struct {
	// contains filtered or unexported fields
}

func NewCallStack added in v0.17.4

func NewCallStack() *CallStack

func (*CallStack) Back added in v0.17.4

func (cs *CallStack) Back() (string, bool)

func (*CallStack) Hash added in v0.17.4

func (cs *CallStack) Hash() string

func (*CallStack) Pop added in v0.17.4

func (cs *CallStack) Pop()

func (*CallStack) Push added in v0.17.4

func (cs *CallStack) Push(entry string) error

Push only errors if a cycle is detected.

func (*CallStack) Stack added in v0.17.4

func (cs *CallStack) Stack() []string

type Set added in v0.21.0

type Set[T comparable] map[T]struct{}

func SetFromSlice added in v0.21.0

func SetFromSlice[T comparable](arr []T) Set[T]

func (*Set[T]) Has added in v0.21.0

func (s *Set[T]) Has(el T) bool

type SourcesRoot added in v0.20.0

type SourcesRoot struct {
	FoundFile string
	AbsDir    string
}

type Vector

type Vector struct {
	X int
	Y int
}

func Vec

func Vec(x int, y int) Vector

func (*Vector) Minus

func (v *Vector) Minus(other Vector) Vector

Jump to

Keyboard shortcuts

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