Endo API documentation - v0.2.0 / Exports / @endo/common / object-meta-map
Module: object-meta-map
Table of contents
Functions
Functions
objectMetaMap
▸ objectMetaMap<O
>(original
, metaMapFn
, proto?
): any
Like objectMap
, but at the reflective level of property descriptors rather than property values.
Except for hardening, the edge case behavior is mostly the opposite of the objectMap
edge cases.
- No matter how mutable the original object, the returned object is hardened.
- All own properties of the original are mapped, even if symbol-named or non-enumerable.
- If any of the original properties were accessors, the descriptor containing the getter and setter are given to
metaMapFn
. - The own properties of the returned are according to the descriptors returned by
metaMapFn
. - The returned object will always be a plain object whose state is only these mapped own properties. It will inherit from the third argument if provided, defaulting to
Object.prototype
if omitted.
Because a property descriptor is distinct from undefined
, we bundle mapping and filtering together. When the metaMapFn
returns undefined
, that property is omitted from the result.
Type parameters
Name | Type |
---|---|
O | extends Record <PropertyKey , any > |
Parameters
Name | Type | Default value |
---|---|---|
original | O | undefined |
metaMapFn | (desc : TypedPropertyDescriptor <O [keyof O ]>, key : keyof O ) => undefined | PropertyDescriptor | undefined |
proto? | any | Object.prototype |
Returns
any