collections

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultValueVar = "value"
	DefaultKeyVar   = "key"
)

Variables

This section is empty.

Functions

func IsValidSortDirection

func IsValidSortDirection(direction SortDirection) bool

func ToSlice

func ToSlice(ctx context.Context, scope *core.Scope, iterator Iterator) ([]*core.Scope, error)

Types

type Collection

type Collection interface {
	core.Value
	Length() values.Int
}

type CollectionIterator added in v0.5.0

type CollectionIterator interface {
	Next(ctx context.Context) (value core.Value, key core.Value, err error)
}

type Comparator

type Comparator func(ctx context.Context, first, second *core.Scope) (int, error)

type FilterIterator

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

func NewFilterIterator

func NewFilterIterator(values Iterator, predicate FilterPredicate) (*FilterIterator, error)

func (*FilterIterator) Next

func (iterator *FilterIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type FilterPredicate

type FilterPredicate func(ctx context.Context, scope *core.Scope) (bool, error)

type HTMLNodeIterator

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

func (*HTMLNodeIterator) Next

func (iterator *HTMLNodeIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type IndexedCollection added in v0.4.0

type IndexedCollection interface {
	Collection
	Get(idx values.Int) core.Value
	Set(idx values.Int, value core.Value) error
}

type IndexedIterator added in v0.4.0

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

func (*IndexedIterator) Next added in v0.4.0

func (iterator *IndexedIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type Iterable

type Iterable interface {
	Iterate(ctx context.Context, scope *core.Scope) (Iterator, error)
}

type IterableCollection added in v0.5.0

type IterableCollection interface {
	core.Value
	Iterate(ctx context.Context) (CollectionIterator, error)
}

type Iterator

type Iterator interface {
	Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)
}

func NewCollectionIterator added in v0.5.0

func NewCollectionIterator(
	valVar,
	keyVar string,
	values CollectionIterator,
) (Iterator, error)

func NewDefaultIndexedIterator added in v0.4.0

func NewDefaultIndexedIterator(
	values IndexedCollection,
) (Iterator, error)

func NewDefaultKeyedIterator added in v0.4.0

func NewDefaultKeyedIterator(input KeyedCollection) (Iterator, error)

func NewDefaultMapIterator added in v0.4.0

func NewDefaultMapIterator(values map[string]core.Value) (Iterator, error)

func NewDefaultSliceIterator added in v0.4.0

func NewDefaultSliceIterator(input []core.Value) (Iterator, error)

func NewHTMLNodeIterator

func NewHTMLNodeIterator(
	valVar,
	keyVar string,
	values values.HTMLNode,
) (Iterator, error)

func NewIndexedIterator added in v0.4.0

func NewIndexedIterator(
	valVar,
	keyVar string,
	values IndexedCollection,
) (Iterator, error)

func NewKeyedIterator added in v0.4.0

func NewKeyedIterator(
	valVar,
	keyVar string,
	values KeyedCollection,
) (Iterator, error)

func NewMapIterator

func NewMapIterator(
	valVar,
	keyVar string,
	values map[string]core.Value,
) (Iterator, error)

func NewSliceIterator

func NewSliceIterator(
	valVar,
	keyVar string,
	values []core.Value,
) (Iterator, error)

func NewTapIterator added in v0.5.0

func NewTapIterator(values Iterator, predicate core.Expression) (Iterator, error)

type KeyedCollection added in v0.4.0

type KeyedCollection interface {
	Collection
	Keys() []string
	Get(key values.String) (core.Value, values.Boolean)
	Set(key values.String, value core.Value)
}

type KeyedIterator added in v0.4.0

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

func (*KeyedIterator) Next added in v0.4.0

func (iterator *KeyedIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type LimitIterator

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

func NewLimitIterator

func NewLimitIterator(values Iterator, count, offset int) (*LimitIterator, error)

func (*LimitIterator) Next

func (iterator *LimitIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type MapIterator

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

func (*MapIterator) Next

func (iterator *MapIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type SliceIterator

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

func (*SliceIterator) Next

func (iterator *SliceIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type SortDirection

type SortDirection int
const (
	SortDirectionAsc  SortDirection = 1
	SortDirectionDesc SortDirection = -1
)

func SortDirectionFromString

func SortDirectionFromString(str string) SortDirection

type SortIterator

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

func NewSortIterator

func NewSortIterator(
	values Iterator,
	comparators ...*Sorter,
) (*SortIterator, error)

func (*SortIterator) Next

func (iterator *SortIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type Sorter

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

func NewSorter

func NewSorter(fn Comparator, direction SortDirection) (*Sorter, error)

type TapIterator added in v0.5.0

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

func (*TapIterator) Next added in v0.5.0

func (iterator *TapIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type UniqueIterator

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

func NewUniqueIterator

func NewUniqueIterator(values Iterator, hashKey string) (*UniqueIterator, error)

func (*UniqueIterator) Next

func (iterator *UniqueIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

Jump to

Keyboard shortcuts

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