Array

package
v0.0.0-...-711c81c Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(
	items []interface{},
	pred func(int, interface{}) Result.Interface,
) Result.Interface

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

func Any(
	items []interface{},
	pred func(int, interface{}) Result.Interface,
) Result.Interface

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 Each

func Each(
	items []interface{},
	fn func(int, interface{}) Result.Interface,
) Result.Interface

Iterate over an Array of interface{}

func Filter

func Filter(
	items []interface{},
	pred func(int, interface{}) Result.Interface,
) Result.Interface

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

func Find(
	items []interface{},
	pred func(int, interface{}) Result.Interface,
) Result.Interface

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

func IndexOf(items []interface{}, item interface{}) Result.Interface

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

func Map(
	items []interface{},
	fn func(int, interface{}) Result.Interface,
) Result.Interface

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.

func Slice

func Slice(items []interface{}, start, end int) Result.Interface

Slice returns a Result whose payload is a NEW independent Array.Interface holding the elements [start:end) of an Array of interface{}. It yields an error Result when start<0 || end>len(items) || start>end.

func Sort

func Sort(
	items []interface{},
	less func(a, b interface{}) bool,
) Result.Interface

Sort orders an Array of interface{} in place using sort.SliceStable with less; the payload is the slice header's backing Array.

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
}

func New

func New() Interface

func Null

func Null() Interface

Null returns the Null-Object Array.

Jump to

Keyboard shortcuts

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