Object

The Object unit in RightJS has some pretty much standard additional methods, which provide frequently used functionalities to process objects.

Methods

empty, keys, merge, only, toQueryString, values, without

top ↑empty

Object.empty(Object object) -> boolean

Description

Checks if the object has any key-value pairs in it.

Example

Object.empty({'a':1}) // -> false
Object.empty({}) // -> true

top ↑keys

Object.keys(Object object) -> Array keys

Description

Collects the object keys into an array.

Example

Object.keys({'a':1, 'b':2, 'c':3})

// -> ['a', 'b', 'c']

top ↑merge

Object.merge(Object o1, Object o2[, objects..]) -> Object new

Description

Creates a new object that contains all the key-value pairs of the given objects.

Example

Object.merge({'a': 1, 'b': 2}, {'c': 3});

// -> {'a': 1, 'b': 2, 'c': 3}

top ↑only

Object.only(Object object, String key[, keys...]) -> Object new

Description

Creates a copy of the object with only the specified key-value paris in it.

Example

var object = {'a': 1, 'b': 2, 'c': 3};
Object.only(object, 'b', 'c');

// -> {'b': 2, 'c': 3}

top ↑toQueryString

Object.toQueryString(Object object) -> String

Description

Converts the object into a URL options string

Example

Object.toQueryString({a:'a', b:'b', c:'%#?'}));

// -> 'a=a&b=b&c=%25%23%3F'

top ↑values

Object.values(Object object) -> Array values

Description

Collects the object values into an array.

Example

Object.values({'a':1, 'b':2, 'c':3})

// -> [1, 2, 3]

top ↑without

Object.without(Object object, String key[, keys..]) -> Object new

Description

Creates a copy of the object without the specified key-value pairs in it.

Example

var object = {'a': 1, 'b': 2, 'c': 3};
Object.without(object, 'b');

// -> {'a': 1, 'c': 3}