lexicon

package
v0.0.0-...-3a26ebd Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: MIT Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexicon

type Lexicon map[string]interface{}

Lexicon is a map-like object whose methods are used to perform traversal and mutation operations by key-value pair.

func New

func New() *Lexicon

New instantiates a new empty Lexicon pointer. Lexicon pointers are mutable and hold and arguments as an interface. Unlike basic map-like objects, the Lexicon provides safe getters and setters, aiming to reduce the likelyhood of an exception being thrown during an operation.

func (*Lexicon) Add

func (pointer *Lexicon) Add(key string, value interface{}) *Lexicon

Add method adds one element to the Lexicon using the key reference and returns the modified Lexicon.

func (*Lexicon) Concatenate

func (pointer *Lexicon) Concatenate(lexicon *Lexicon) *Lexicon

Concatenate merges two Lexicons.

func (*Lexicon) Each

func (pointer *Lexicon) Each(f func(key string, value interface{})) *Lexicon

Each method executes a provided function once for each Lexicon element.

func (*Lexicon) Fetch

func (pointer *Lexicon) Fetch(key string) interface{}

Fetch retrieves the interface held by the argument key. Returns nil if key does not exist.

func (*Lexicon) Get

func (pointer *Lexicon) Get(key string) (interface{}, bool)

Get returns the interface held by the argument key and a boolean indicating if it was successfully retrieved.

func (*Lexicon) Has

func (pointer *Lexicon) Has(key string) bool

Has method checks that a given key exists in the Lexicon.

func (*Lexicon) Keys

func (pointer *Lexicon) Keys() *slice.Slice

Keys method returns a Slice of a given Lexicon's own property names, in the same order as we get with a normal loop.

func (*Lexicon) Len

func (pointer *Lexicon) Len() int

Len method returns the number of elements in the Lexicon.

func (*Lexicon) Map

func (pointer *Lexicon) Map(f func(key string, value interface{}) interface{}) *Lexicon

Map method executes a provided function once for each Lexicon element and sets the returned value to the current key.

func (*Lexicon) Missing

func (pointer *Lexicon) Missing(key string) bool

Missing method checks if a key is not present in the Lexicon.

func (*Lexicon) Remove

func (pointer *Lexicon) Remove(key string) bool

Remove method removes a entry from the Lexicon if it exists. Returns a boolean to confirm if it succeeded.

func (*Lexicon) Replace

func (pointer *Lexicon) Replace(key string, value interface{}) bool

Replace method changes the contents of the Lexicon at the argument key if it exists in the Lexicon.

func (*Lexicon) Values

func (pointer *Lexicon) Values() *slice.Slice

Values method returns a Slice of a given Lexicon's own enumerable property values, in the same order as that provided by a for...in loop.

Jump to

Keyboard shortcuts

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