list

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package list implements a kiwi.Value which can store an array of strings.

Index

Constants

View Source
const (
	// Get gets the string at the particular index.
	// If no index is provided it gets the last element.
	//
	// Returns a string.
	Get kiwi.Action = "GET"

	// Set sets the value of string at the index.
	// If no index is given and just the string, it updates the last element.
	//
	// Returns the sett-ed string.
	Set kiwi.Action = "SET"

	// Slice gets slice of the array from begin to end ( excluded ).
	//
	// Returns a slice of strings.
	Slice kiwi.Action = "SLICE"

	// Len gets the length of the list.
	//
	// Returns an integer.
	Len kiwi.Action = "LEN"

	// Append adds elements to the end of list.
	//
	// Returns a slice of strings which are appended.
	Append kiwi.Action = "APPEND"

	// Pop removes the last "n" elements from the string.
	// If "n" is not provided, pops last element.
	//
	// Returns a slice of removed strings.
	Pop kiwi.Action = "POP"

	// Remove removes the elements specified from the list.
	// These can be indexes or the elements themselves.
	//
	// Returns the removed string.
	Remove kiwi.Action = "REMOVE"

	// Find gets the index of element if it exists else -1.
	//
	// Returns an integer.
	Find kiwi.Action = "FIND"
)
View Source
const Type kiwi.ValueType = "list"

Type of list value.

Variables

View Source
var (
	ErrInvalidIndex     = fmt.Errorf("cannot access invalid index")
	ErrInvalidParamLen  = fmt.Errorf("not enough parameters")
	ErrInvalidParamType = fmt.Errorf("invalid paramater type")
)

Various errors for list value type.

Functions

This section is empty.

Types

type Value

type Value []string

Value can store an array of strings.

It implements the kiwi.Value interface.

func (*Value) DoMap

func (v *Value) DoMap() map[kiwi.Action]kiwi.DoFunc

DoMap returns the map of v's actions with it's do functions.

func (*Value) FromJSON

func (v *Value) FromJSON(rawmessage json.RawMessage) error

FromJSON populates the s with the data from RawMessage

func (*Value) ToJSON

func (v *Value) ToJSON() (json.RawMessage, error)

ToJSON returns the raw byte array of s's data

func (*Value) Type

func (v *Value) Type() kiwi.ValueType

Type returns v's type, i.e., "list".

Jump to

Keyboard shortcuts

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