API Docs for: 0.0.8-0
Show:

Dictionary Class

A set of useful functions for manipulating dictionaries.

Item Index

Methods

Methods

clone

(
  • dict
)
Object static

Returns a shallow copy of the given dictionary.

Parameters:

Returns:

Object:

a shallow copy of the given dictionary

find

(
  • dict
  • fcn
  • [compareFcn]
)
static

Iterates over the key-value pair in the given dictionary and returns the index of the first element to cause the given fcn to return true.

Parameters:

  • dict Object

    a dictionary object

  • fcn Function

    a function that takes the following parameters:

    • the key
    • the value and returns true if the given key or value satisfy some condition
  • [compareFcn] Function optional

    a comparator function (takes two arguments and returns an integer) used to sort the keys

forEachEntry

(
  • dict
  • fcn
  • [sortFcn]
  • [scope]
)
static

Iterates over the key-value pair in the given dictionary (in arbitrary order) and calls the given function on each key-value pair.

Parameters:

  • dict Object

    a dictionary object

  • fcn Function

    a function that takes the following parameters:

    • the key
    • the value
    • obj (an optional parameter) that contains two fields, exit and returnVal. If exit is set to true, forEachEntry terminates right away (without iterating over the rest of the dictionary). The return value of forEackKeyValuePair is returnVal (which by default is undefined).
  • [sortFcn] Function optional

    true if the dictionary keys are to be sorted before iterating

  • [scope] Object optional

    The scope to be hitched to the given fcn

isEmpty

(
  • dict
)
Boolean static

Returns true if the given dictionary is empty (i.e. has no keys)

Parameters:

Returns:

Boolean:

true if the dictionary is empty, false otherwise

length

(
  • dict
)
Integer static

Returns the number of keys in the given dictionary.

Parameters:

Returns:

Integer:

the number of keys in the dictionary