# object Locked, prototype-pollution-resistant copies of the global `Object` static methods. References to `Object.freeze`, `Object.create`, `Object.keys`, `Object.values`, `Object.entries`, `Object.assign`, `Object.defineProperty`, and the rest of the `Object` static surface are captured at module-load time and frozen into a tamper-proof namespace, so downstream code keeps working even if the global `Object` is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain. ## API Reference ### Functions #### hasOwn ```typescript function hasOwn(obj: object, key: PropertyKey): boolean ``` (Safe copy) Safe wrapper for Object.prototype.hasOwnProperty.call(). Checks if an object has a property as its own (not inherited) property. **Parameters** | Name | Type | Description | | --- | --- | --- | | `obj` | `object` | The object to check. | | `key` | `PropertyKey` | The property key to check. | **Returns** `boolean`: True if the object has the property as its own property. **Example: Checking own properties** ```typescript const user = { name: 'Alice' } hasOwn(user, 'name') // => true hasOwn(user, 'toString') // => false (inherited from prototype) ``` #### typeTag ```typescript function typeTag(value: unknown): string ``` (Safe copy) Safe wrapper for Object.prototype.toString.call(). Returns the internal [[Class]] property of the object as a string tag. **Parameters** | Name | Type | Description | | --- | --- | --- | | `value` | `unknown` | The value to get the type tag from. | **Returns** `string`: The type tag string (e.g., "[object Array]"). **Example: Getting type tags** ```typescript typeTag([1, 2, 3]) // => '[object Array]' typeTag(null) // => '[object Null]' typeTag(Promise.resolve()) // => '[object Promise]' ``` ### Variables #### assign (Safe copy) Copy the values of all enumerable own properties from one or more source objects to a target object. Returns the target object. ```typescript const assign: (target: T, source: U) => T & U ``` **Value** `_Object.assign` #### create (Safe copy) Creates an object that has the specified prototype or that has null prototype. ```typescript const create: (o: object) => any ``` **Value** `_Object.create` #### defineProperties (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties. ```typescript const defineProperties: (o: T, properties: PropertyDescriptorMap & ThisType) => T ``` **Value** `_Object.defineProperties` #### defineProperty (Safe copy) Adds a property to an object, or modifies attributes of an existing property. ```typescript const defineProperty: (o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType) => T ``` **Value** `_Object.defineProperty` #### entries (Safe copy) Returns an array of key/values of the enumerable own properties of an object. ```typescript const entries: (o: { } | ArrayLike) => [string, T][] ``` **Value** `_Object.entries` #### freeze (Safe copy) Prevents modification of existing property attributes and values, and prevents the addition of new properties. ```typescript const freeze: (f: T) => T ``` **Value** `_Object.freeze` #### fromEntries (Safe copy) Returns an object from an iterable of key-value pairs. ```typescript const fromEntries: (entries: Iterable) => { } ``` **Value** `_Object.fromEntries` #### getOwnPropertyDescriptor (Safe copy) Gets the own property descriptor of the specified object. ```typescript const getOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor ``` **Value** `_Object.getOwnPropertyDescriptor` #### getOwnPropertyDescriptors (Safe copy) Gets the own property descriptors of the specified object. ```typescript const getOwnPropertyDescriptors: (o: T) => mapped & { } ``` **Value** `_Object.getOwnPropertyDescriptors` #### getOwnPropertyNames (Safe copy) Returns the names of the own properties of an object. ```typescript const getOwnPropertyNames: (o: any) => string[] ``` **Value** `_Object.getOwnPropertyNames` #### getOwnPropertySymbols (Safe copy) Returns an array of all symbol properties found directly on object o. ```typescript const getOwnPropertySymbols: (o: any) => symbol[] ``` **Value** `_Object.getOwnPropertySymbols` #### getPrototypeOf (Safe copy) Returns the prototype of an object. ```typescript const getPrototypeOf: (o: any) => any ``` **Value** `_Object.getPrototypeOf` #### isExtensible (Safe copy) Returns a value that indicates whether new properties can be added to an object. ```typescript const isExtensible: (o: any) => boolean ``` **Value** `_Object.isExtensible` #### isFrozen (Safe copy) Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. ```typescript const isFrozen: (o: any) => boolean ``` **Value** `_Object.isFrozen` #### isSealed (Safe copy) Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. ```typescript const isSealed: (o: any) => boolean ``` **Value** `_Object.isSealed` #### keys (Safe copy) Returns the names of the enumerable string properties and methods of an object. ```typescript const keys: (o: object) => string[] ``` **Value** `_Object.keys` #### objectHasOwn (Safe copy) Determines whether an object has a property with the specified name. ```typescript const objectHasOwn: (o: object, v: PropertyKey) => boolean ``` **Value** `_Object.hasOwn` #### preventExtensions (Safe copy) Prevents the addition of new properties to an object. ```typescript const preventExtensions: (o: T) => T ``` **Value** `_Object.preventExtensions` #### SafeObject (Safe copy) Namespace object containing all Object static methods. Note: Importing this imports all methods in this namespace (no tree-shaking). Named SafeObject instead of Object to avoid shadowing global Object during CJS module initialization. ```typescript const SafeObject: Readonly<{ assign: (target: T, source: U) => T & U; create: (o: object) => any; defineProperties: (o: T, properties: PropertyDescriptorMap & ThisType) => T; defineProperty: (o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType) => T; entries: (o: { } | ArrayLike) => [string, T][]; freeze: (f: T) => T; fromEntries: (entries: Iterable) => { }; getOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor; getOwnPropertyDescriptors: (o: T) => mapped & { }; getOwnPropertyNames: (o: any) => string[]; getOwnPropertySymbols: (o: any) => symbol[]; getPrototypeOf: (o: any) => any; hasOwn: (o: object, v: PropertyKey) => boolean; isExtensible: (o: any) => boolean; isFrozen: (o: any) => boolean; isSealed: (o: any) => boolean; keys: (o: object) => string[]; preventExtensions: (o: T) => T; seal: (o: T) => T; setPrototypeOf: (o: any, proto: object) => any; values: (o: { } | ArrayLike) => T[] }> ``` **Value** `...` #### seal (Safe copy) Prevents the addition of new properties to an object. ```typescript const seal: (o: T) => T ``` **Value** `_Object.seal` #### setPrototypeOf (Safe copy) Sets the prototype of a specified object o to object proto or null. ```typescript const setPrototypeOf: (o: any, proto: object) => any ``` **Value** `_Object.setPrototypeOf` #### values (Safe copy) Returns an array of values of the enumerable own properties of an object. ```typescript const values: (o: { } | ArrayLike) => T[] ``` **Value** `_Object.values` --- Canonical page: https://www.hyperfrontend.dev/docs/libraries/utils/immutable-api/built-in-copy/object/ This file: https://www.hyperfrontend.dev/docs/libraries/utils/immutable-api/built-in-copy/object.md Documentation index: https://www.hyperfrontend.dev/llms.txt