We use cookies to make our website more effective. By using our website you agree to our privacy policy.

Namespace: maps

maps

maps.js is part of Aloha Editor project http://www.alohaeditor.org

Aloha Editor ● JavaScript Content Editing Library
Copyright (c) 2010-2015 Gentics Software GmbH, Vienna, Austria.
Contributors http://www.alohaeditor.org/docs/contributing.html

Methods

clone(map){Object}

Clones a map.
Name Type Description
map Object

cloneDelete(map, key){Object}

Deletes a key from a clone of the given map and returns the clone.
Name Type Description
map Object
key string

cloneSet(map, key, value){Object}

Sets a value on a clone of the given map and returns the clone.
Name Type Description
map Object
key string
value *

create(){Object}

Creates a map without inheriting from Object.

Use this instead of an object literal to avoid having unwanted, inherited
properties on the map.

A map constructed like this allows for the
```for (var key in map) { }```
pattern to be used without a hasOwnProperty check.

extend()

This function is missing documentation.
TODO
  • Complete documentation.

fillKeys(map, keys, value){Object}

Fills the given map with the given keys mapped to the given value.
Name Type Description
map Object The given map will have one entry added for each given key.
keys Array.<string> An array of string keys. JavaScript maps can only contain string keys, so these must be strings or they will be cast to string.
value string A single value that each given key will map to.
Returns:
given map.

filter()

Same as Array.filter except for maps.

The given predicate is applied to each entry in the given map,
and only if the predicate returns true, will the entry appear in
the result.

forEach()

For each mapping, calls `cb(value, key, m)`.

Like ECMAScript edition 5 Array.forEach but for Maps.

Contrary to "for (key in m)" iterates only over the "hasOwnProperty"
properties of the m, which is usually what you want.

isEmpty(obj){boolean}

Checks whether the given object has no own or inherited properties.
Name Type Description
obj Object Object to check.
Returns:
if the object is empty. eg: isEmpty({}) == true

isMap()

Whether the given object is a map that can be operated on by
other functions in this module.

We exclude things like new String("..."), new Number(...),
document.createElement(...), but include new MyType("...").

keys(m){Array}

Returns an array of the map's keys.
Name Type Description
m Object
Returns:
set of keys in `m`.

mapTuples(tuples){Object.<string, *>}

Converts a list of tuples into a hash map key-value pair.
Name Type Description
tuples Array.<Array.<string, *>>

merge(A){Object}

Merges one or more maps.
Merging happens from left to right, which is useful for example
when merging a number of given options with default options:
var effectiveOptions = Maps.merge(defaults, options);
Name Type Description
A Object repeatable variable number of map objects.
Returns:
merge of all given maps in a single object.

selectVals(m, ks, _default){Array}

Selects the values for the given keys in the given map.
Name Type Description
m Object
ks Array
_default * used in place of non-existing properties

vals(m){Array}

Returns an array of the map's values.
Name Type Description
m Object
Returns:
values in `m`.
comments powered by Disqus