goog.object
Exported Functions
add<K, V>( obj, key, val ) → void
void
clear( obj ) → void
void
Removes all key value pairs from the object/map/hash.
Parameters |
|
---|
clone<K, V>( obj ) → Object<(K|null), (V|null)>
Object<(K|null), (V|null)>
contains<K, V>( obj, val ) → boolean
boolean
containsKey( obj, key ) → boolean
boolean
containsValue<K, V>( obj, val ) → boolean
boolean
create( ...var_args ) → Object
Object
Creates a new object built from the key-value pairs provided as arguments.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
Throws |
|
createImmutableView<K, V>( obj ) → Object<(K|null), (V|null)>
Object<(K|null), (V|null)>
Creates an immutable view of the underlying object, if the browser supports immutable objects. In default mode, writes to this view will fail silently. In strict mode, they will throw an error.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
createSet( ...var_args ) → Object
Object
Creates a new object where the property names come from the arguments but the value is always set to true
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
equals<K, V>( a, b ) → boolean
boolean
every<T, K, V>( obj, f, opt_obj ) → boolean
boolean
Calls a function for each element in an object/map/hash. If all calls return true, returns true. If any call returns false, returns false at this point and does not continue to check the remaining elements.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
extend( target, ...var_args ) → void
void
Extends an object with another object. This operates 'in-place'; it does not create a new Object. Example: var o = {}; extend(o, {a: 0, b: 1}); o; // {a: 0, b: 1} extend(o, {b: 2, c: 3}); o; // {a: 0, b: 2, c: 3}
warning Deprecated | Prefer Object.assign |
---|
Parameters |
|
---|
filter<T, K, V>( obj, f, opt_obj ) → Object<(K|null), (V|null)>
Object<(K|null), (V|null)>
Calls a function for each element in an object/map/hash. If that call returns true, adds the element to a new object.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
findKey<T, K, V>( obj, f, thisObj ) → (string|undefined)
(string|undefined)
Searches an object for an element that satisfies the given condition and returns its key.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
findValue<T, K, V>( obj, f, thisObj ) → V
V
Searches an object for an element that satisfies the given condition and returns its value.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
forEach<T, K, V>( obj, f, opt_obj ) → void
void
Calls a function for each element in an object/map/hash.
Parameters |
|
---|
get<K, V, R>( obj, key, val ) → ?
?
Get all properties names on a given Object regardless of enumerability.
If the browser does not support `Object.getOwnPropertyNames` nor `Object.getPrototypeOf` then this is equivalent to using `getKeys`
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
getAnyKey( obj ) → (string|undefined)
(string|undefined)
getAnyValue<K, V>( obj ) → ?
?
Returns one value from the object map, if any exists. For map literals the returned value will be the first one in most of the browsers (a know exception is Konqueror).
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getCount( obj ) → number
number
getSuperClass( constructor ) → (Object|null)
(Object|null)
Given a ES5 or ES6 class reference, return its super class / super
constructor.
This should be used in rare cases where you need to walk up the inheritance
tree (this is generally a bad idea). But this work with ES5 and ES6 classes,
unlike relying on the superClass_ property.
Note: To start walking up the hierarchy from an instance call this with its
constructor
property; e.g. getSuperClass(instance.constructor)
.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getValueByKeys( obj, ...var_args ) → *
*
Get a value from an object multiple levels deep. This is useful for pulling values from deeply nested objects, such as JSON responses. Example usage: getValueByKeys(jsonObj, 'foo', 'entries', 3)
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getValues<K, V>( obj ) → Array<(V|null)>
Array<(V|null)>
isEmpty( obj ) → boolean
boolean
isImmutableView( obj ) → boolean
boolean
map<T, K, V, R>( obj, f, opt_obj ) → Object<(K|null), (R|null)>
Object<(K|null), (R|null)>
For every element in an object/map/hash calls a function and inserts the result into a new object.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
remove( obj, key ) → boolean
boolean
set<K, V>( obj, key, value ) → void
void
setIfUndefined<K, V>( obj, key, value ) → V
V
Adds a key-value pair to the object/map/hash if it doesn't exist yet.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
setWithReturnValueIfNotSet<K, V>( obj, key, f ) → V
V
Sets a key and value to an object if the key is not set. The value will be
the return value of the given function. If the key already exists, the
object will not be changed and the function will not be called (the function
will be lazily evaluated -- only called if necessary).
This function is particularly useful when used with an Object
which is
acting as a cache.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
some<T, K, V>( obj, f, opt_obj ) → boolean
boolean
Calls a function for each element in an object/map/hash. If any call returns true, returns true (without checking the rest). If all calls return false, returns false.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
transpose( obj ) → Object
Object
unsafeClone<T>( obj ) → T
T
Clones a value. The input may be an Object, Array, or basic type. Objects and
arrays will be cloned recursively.
WARNINGS:
unsafeClone
does not detect reference loops. Objects
that refer to themselves will cause infinite recursion.
unsafeClone
is unaware of unique identifiers, and
copies UIDs created by getUid
into cloned results.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|