or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

arrays.mdassertions.mdcore.mddom.mdevents.mdindex.mdmath.mdobjects.mdstrings.md
tile.json

objects.mddocs/

Object Utilities

Object manipulation utilities including iteration, property management, comparison, cloning, and extension operations for comprehensive object processing.

Capabilities

Object Iteration

Functions for iterating over object properties and values.

/**
 * Iterates over object properties
 * @param {Object} obj - Object to iterate over
 * @param {function(*, string, Object)} f - Iterator function (value, key, object)
 * @param {Object=} opt_obj - Object to bind 'this' to
 */
goog.object.forEach = function(obj, f, opt_obj) {};

/**
 * Creates new object with filtered properties
 * @param {Object} obj - Object to filter
 * @param {function(*, string, Object): boolean} f - Filter function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {Object} Filtered object
 */
goog.object.filter = function(obj, f, opt_obj) {};

/**
 * Creates new object with transformed values
 * @param {Object} obj - Object to map
 * @param {function(*, string, Object): *} f - Transform function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {Object} Object with transformed values
 */
goog.object.map = function(obj, f, opt_obj) {};

/**
 * Tests if some properties match predicate
 * @param {Object} obj - Object to test
 * @param {function(*, string, Object): boolean} f - Test function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {boolean} True if any property matches
 */
goog.object.some = function(obj, f, opt_obj) {};

/**
 * Tests if all properties match predicate
 * @param {Object} obj - Object to test
 * @param {function(*, string, Object): boolean} f - Test function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {boolean} True if all properties match
 */
goog.object.every = function(obj, f, opt_obj) {};

Property Access

Functions for accessing and examining object properties.

/**
 * Gets array of object keys
 * @param {Object} obj - Object to get keys from
 * @return {Array<string>} Array of property names
 */
goog.object.getKeys = function(obj) {};

/**
 * Gets array of object values
 * @param {Object} obj - Object to get values from
 * @return {Array<*>} Array of property values
 */
goog.object.getValues = function(obj) {};

/**
 * Tests if object contains specified value
 * @param {Object} obj - Object to search
 * @param {*} val - Value to look for
 * @return {boolean} True if value is found
 */
goog.object.contains = function(obj, val) {};

/**
 * Finds key for first property matching predicate
 * @param {Object} obj - Object to search
 * @param {function(*, string, Object): boolean} f - Predicate function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {string|undefined} Key of matching property
 */
goog.object.findKey = function(obj, f, opt_obj) {};

/**
 * Finds value of first property matching predicate
 * @param {Object} obj - Object to search
 * @param {function(*, string, Object): boolean} f - Predicate function
 * @param {Object=} opt_obj - Object to bind 'this' to
 * @return {*} Value of matching property
 */
goog.object.findValue = function(obj, f, opt_obj) {};

/**
 * Tests if object has no enumerable properties
 * @param {Object} obj - Object to test
 * @return {boolean} True if object is empty
 */
goog.object.isEmpty = function(obj) {};

/**
 * Gets property value with optional default
 * @param {Object} obj - Object to get property from
 * @param {string} key - Property name
 * @param {*=} opt_val - Default value if property doesn't exist
 * @return {*} Property value or default
 */
goog.object.get = function(obj, key, opt_val) {};

Property Modification

Functions for modifying object properties.

/**
 * Removes all enumerable properties from object
 * @param {Object} obj - Object to clear
 */
goog.object.clear = function(obj) {};

/**
 * Removes property from object
 * @param {Object} obj - Object to remove property from
 * @param {string} key - Property name to remove
 * @return {boolean} True if property existed and was removed
 */
goog.object.remove = function(obj, key) {};

/**
 * Adds property to object
 * @param {Object} obj - Object to add property to
 * @param {string} key - Property name
 * @param {*} val - Property value
 */
goog.object.add = function(obj, key, val) {};

/**
 * Sets property on object
 * @param {Object} obj - Object to set property on
 * @param {string} key - Property name
 * @param {*} value - Property value
 */
goog.object.set = function(obj, key, value) {};

/**
 * Sets property only if it's currently undefined
 * @param {Object} obj - Object to set property on
 * @param {string} key - Property name
 * @param {*} value - Property value
 */
goog.object.setIfUndefined = function(obj, key, value) {};

/**
 * Sets property using factory function if not already set
 * @param {Object} obj - Object to set property on
 * @param {string} key - Property name
 * @param {function(): *} f - Factory function for value
 * @return {*} The property value (existing or newly created)
 */
goog.object.setWithReturnValueIfNotSet = function(obj, key, f) {};

Object Comparison & Cloning

Functions for comparing and copying objects.

/**
 * Performs deep equality comparison of two objects
 * @param {*} a - First object
 * @param {*} b - Second object
 * @return {boolean} True if objects are deeply equal
 */
goog.object.equals = function(a, b) {};

/**
 * Creates shallow copy of object
 * @param {Object} obj - Object to clone
 * @return {Object} Shallow copy of object
 */
goog.object.clone = function(obj) {};

/**
 * Creates copy without type checking (faster but less safe)
 * @param {Object} obj - Object to clone
 * @return {Object} Unsafe copy of object
 */
goog.object.unsafeClone = function(obj) {};

/**
 * Transposes object keys and values
 * @param {Object} obj - Object to transpose
 * @return {Object} Object with keys and values swapped
 */
goog.object.transpose = function(obj) {};

Object Extension & Creation

Functions for extending objects and creating new objects.

/**
 * Extends target object with properties from source objects
 * @param {Object} target - Target object to extend
 * @param {...Object} var_args - Source objects to copy from
 * @return {Object} Extended target object
 */
goog.object.extend = function(target, var_args) {};

/**
 * Creates object from alternating key-value arguments
 * @param {...*} var_args - Alternating keys and values
 * @return {Object} Created object
 */
goog.object.create = function(var_args) {};

/**
 * Creates set object from values (object with values as keys)
 * @param {...*} var_args - Values to use as keys
 * @return {Object} Set object
 */
goog.object.createSet = function(var_args) {};

Object Entry Processing

Functions for working with key-value pairs.

/**
 * Gets array of [key, value] pairs
 * @param {Object} obj - Object to get entries from
 * @return {Array<Array<*>>} Array of [key, value] pairs
 */
goog.object.getAnyKey = function(obj) {};

/**
 * Gets any value from object (useful for getting first value)
 * @param {Object} obj - Object to get value from
 * @return {*} Any value from object
 */
goog.object.getAnyValue = function(obj) {};

Usage Examples:

// Object iteration
var user = { name: 'Alice', age: 30, active: true };

goog.object.forEach(user, function(value, key) {
    console.log(key + ': ' + value);
});

// Object filtering and mapping
var numbers = { a: 1, b: 2, c: 3, d: 4 };
var evens = goog.object.filter(numbers, function(val) { return val % 2 === 0; });
// Result: { b: 2, d: 4 }

var doubled = goog.object.map(numbers, function(val) { return val * 2; });
// Result: { a: 2, b: 4, c: 6, d: 8 }

// Property access and modification
var keys = goog.object.getKeys(user); // ['name', 'age', 'active']
var hasAge = goog.object.contains(user, 30); // true

goog.object.set(user, 'email', 'alice@example.com');
goog.object.remove(user, 'active');

// Object cloning and extension
var userCopy = goog.object.clone(user);
var extendedUser = goog.object.extend({}, user, { role: 'admin' });

// Object creation utilities
var config = goog.object.create('debug', true, 'timeout', 5000);
// Result: { debug: true, timeout: 5000 }

var validOptions = goog.object.createSet('read', 'write', 'delete');
// Result: { read: true, write: true, delete: true }