Object manipulation helpers provide utilities for object extension, property management, and destructuring operations with cross-environment compatibility and polyfill support.
Enhanced Object.assign() implementation with polyfill support for object extension.
/**
* Object.assign() polyfill and enhancement
* @param target - Target object to extend
* @param sources - Source objects to copy properties from
* @returns Extended target object
*/
function _extends(target: any, ...sources: any[]): any;Usage Example:
import _extends from '@babel/runtime/helpers/esm/extends';
// Used by Babel for: const config = { ...defaultConfig, ...userConfig };
const config = _extends({}, defaultConfig, userConfig);
// Also used for: const props = { ...baseProps, onClick: handler };
const props = _extends({}, baseProps, { onClick: handler });Modern object spread operator implementation with symbol property support.
/**
* Modern object spread implementation
* @param target - Target object
* @param sources - Source objects to spread
* @returns New object with spread properties
*/
function objectSpread2(target: any, ...sources: any[]): any;Usage Example:
import _objectSpread2 from '@babel/runtime/helpers/esm/objectSpread2';
// Used by Babel for complex spread operations
const result = _objectSpread2(_objectSpread2({}, obj1), {}, obj2, {
customProp: 'value'
});Legacy object spread implementation (pre-ES2018).
/**
* Object spread operator (legacy)
* @param target - Target object
* @param sources - Source objects
* @returns Object with spread properties
*/
function objectSpread(target: any, ...sources: any[]): any;Applies default properties to an object, only setting undefined properties.
/**
* Applies default properties
* @param obj - Object to apply defaults to
* @param defaults - Default properties to apply
* @returns Object with defaults applied
*/
function defaults(obj: any, ...defaults: any[]): any;Excludes specified properties from an object (rest in destructuring).
/**
* Excludes properties from object
* @param obj - Source object
* @param keys - Property keys to exclude
* @returns New object without specified properties
*/
function objectWithoutProperties(obj: any, keys: string[]): any;Usage Example:
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
// Used by Babel for: const { id, name, ...rest } = user;
const _user = { id: 1, name: 'Alice', email: 'alice@example.com', age: 30 };
const rest = _objectWithoutProperties(_user, ['id', 'name']);
// rest is { email: 'alice@example.com', age: 30 }Loose mode property exclusion (smaller bundle, less strict).
/**
* Loose mode property exclusion (smaller bundle)
* @param obj - Source object
* @param keys - Property keys to exclude
* @returns New object without specified properties
*/
function objectWithoutPropertiesLoose(obj: any, keys: string[]): any;Ensures object exists for destructuring operations (prevents null/undefined errors).
/**
* Ensures object for destructuring
* @param obj - Object to validate for destructuring
* @returns The object or throws TypeError
* @throws TypeError if obj is null or undefined
*/
function objectDestructuringEmpty(obj: any): any;Usage Example:
import _objectDestructuringEmpty from '@babel/runtime/helpers/esm/objectDestructuringEmpty';
// Used by Babel for: const {} = someValue;
const result = _objectDestructuringEmpty(someValue);Enhanced Object.defineProperty() with fallbacks for older environments.
/**
* Defines object properties with fallbacks
* @param obj - Object to define property on
* @param key - Property key
* @param descriptor - Property descriptor
* @returns The object with defined property
*/
function defineProperty(obj: any, key: PropertyKey, descriptor: PropertyDescriptor): any;
interface PropertyDescriptor {
configurable?: boolean;
enumerable?: boolean;
value?: any;
writable?: boolean;
get?(): any;
set?(value: any): void;
}Defines property accessors (getters/setters) with fallback support.
/**
* Defines property accessors
* @param obj - Object to define accessor on
* @param key - Property key
* @param getter - Getter function
* @param setter - Setter function
* @returns The object with defined accessor
*/
function defineAccessor(obj: any, key: PropertyKey, getter?: Function, setter?: Function): any;Defines multiple enumerable properties on an object efficiently.
/**
* Defines multiple enumerable properties
* @param obj - Target object
* @param descs - Property descriptors to define
* @returns Object with defined properties
*/
function defineEnumerableProperties(obj: any, descs: Record<PropertyKey, any>): any;Converts values to valid property keys (string/symbol).
/**
* Converts values to property keys
* @param arg - Value to convert to property key
* @returns String or symbol property key
*/
function toPropertyKey(arg: any): PropertyKey;Converts objects to primitive values using Symbol.toPrimitive or valueOf/toString.
/**
* Converts objects to primitives
* @param input - Input value to convert
* @param hint - Type hint ('string', 'number', or 'default')
* @returns Primitive value
*/
function toPrimitive(input: any, hint?: 'string' | 'number' | 'default'): any;Sets the name property on functions for debugging and introspection.
/**
* Sets function name property
* @param fn - Function to set name on
* @param name - Name to set
* @param prefix - Optional prefix for computed names
* @returns Function with name set
*/
function setFunctionName(fn: Function, name: PropertyKey, prefix?: string): Function;Creates setter functions for property assignment.
/**
* Creates setter functions
* @param fns - Array of functions to convert to setters
* @returns Array of setter functions
*/
function toSetter(fns: Function[]): Function[];// Property key types
type PropertyKey = string | number | symbol;
// Property descriptor interface
interface PropertyDescriptor {
configurable?: boolean;
enumerable?: boolean;
value?: any;
writable?: boolean;
get?(): any;
set?(value: any): void;
}
// Property descriptor map
type PropertyDescriptorMap = Record<PropertyKey, PropertyDescriptor>;
// Object extension target
interface ObjectExtensionTarget {
[key: PropertyKey]: any;
}
// Primitive conversion hint
type ToPrimitiveHint = 'string' | 'number' | 'default';