Documentation
¶
Index ¶
- func All(items []interface{}, pred func(int, interface{}) Result.Interface) Result.Interface
- func Any(items []interface{}, pred func(int, interface{}) Result.Interface) Result.Interface
- func Each(items []interface{}, fn func(int, interface{}) Result.Interface) Result.Interface
- func Filter(items []interface{}, pred func(int, interface{}) Result.Interface) Result.Interface
- func Find(items []interface{}, pred func(int, interface{}) Result.Interface) Result.Interface
- func IndexOf(items []interface{}, item interface{}) Result.Interface
- func Map(items []interface{}, fn func(int, interface{}) Result.Interface) Result.Interface
- func Reduce(items []interface{}, seed interface{}, ...) Result.Interface
- func Slice(items []interface{}, start, end int) Result.Interface
- func Sort(items []interface{}, less func(a, b interface{}) bool) Result.Interface
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All reports whether every item of an Array of interface{} satisfies pred. It returns a Result whose payload is a Go bool. It short-circuits: a pred error is propagated, the first falsy item yields a false payload, and an empty Array yields a true payload (vacuous truth).
func Any ¶
Any reports whether at least one item of an Array of interface{} satisfies pred. It returns a Result whose payload is a Go bool. It short-circuits: a pred error is propagated (the error Result is returned), the first truthy item yields a true payload, and an empty Array (or no match) yields a false payload.
func Filter ¶
Filter keeps the items of an Array of interface{} whose pred returns a non-error, truthy Result, collecting them into a new Array. It short-circuits on the first error Result; on a full pass it returns a Result whose payload is the new Array.Interface.
func Find ¶
Find returns the first item of an Array of interface{} for which pred returns a non-error, truthy Result, as the payload of a successful Result. It short-circuits on the first error Result; when no item matches it returns a Result carrying a not-found Error.
func IndexOf ¶
IndexOf returns, as a Result whose payload is a Go int, the index of the first element of an Array of interface{} equal to item (compared with reflect.DeepEqual), or -1 when no element matches.
func Map ¶
Map applies fn to each item of an Array of interface{}, collecting the non-error payloads into a brand new Array. It short-circuits, returning the first error Result it encounters; on a full pass it returns a Result whose payload is the new Array.Interface.
func Reduce ¶
func Reduce(
items []interface{},
seed interface{},
fn func(acc, item interface{}) Result.Interface,
) Result.Interface
Reduce performs a left fold over an Array of interface{}, threading an accumulator through fn while propagating Result errors. It short-circuits on the first error Result; on a full pass it returns a Result whose payload is the final accumulator value.
Types ¶
type Interface ¶
type Interface interface {
Each(fn func(int, interface{}) Result.Interface) Result.Interface
Map(fn func(int, interface{}) Result.Interface) Result.Interface
Filter(pred func(int, interface{}) Result.Interface) Result.Interface
Reduce(seed interface{}, fn func(acc, item interface{}) Result.Interface) Result.Interface
Find(pred func(int, interface{}) Result.Interface) Result.Interface
Any(pred func(int, interface{}) Result.Interface) Result.Interface
All(pred func(int, interface{}) Result.Interface) Result.Interface
Push(interface{}) Result.Interface
Pop() Result.Interface
First() Result.Interface
Fetch(int) Result.Interface
Last() Result.Interface
Clear() Result.Interface
Copy() Result.Interface
Len() int
IsEmpty() bool
Contains(item interface{}) Result.Interface
Insert(index int, item interface{}) Result.Interface
Delete(index int) Result.Interface
Reverse() Result.Interface
Sort(less func(a, b interface{}) bool) Result.Interface
IndexOf(item interface{}) Result.Interface
Slice(start, end int) Result.Interface
IsNull() bool
}