Interface MirrorObjectThroughCompositionConfig<P>

configuration options for the function mirrorObjectThroughComposition.

interface MirrorObjectThroughCompositionConfig<P extends PropertyKey = string> {
    baseKey: P;
    mirrorPrototype?: boolean | PrototypeChainOfObjectConfig | Object[];
    propertyKeys?: Iterable<PropertyKey>;
    ignoreKeys?: Iterable<PropertyKey>;
    target?: object;
}

Type Parameters

  • P extends PropertyKey = string

Properties

baseKey: P

the key to use to access the composed base object.

mirrorPrototype?: boolean | PrototypeChainOfObjectConfig | Object[]

specify whether or not the given object's prototype methods and properties should also be mimicked/mirrored.

for fine-grained control of which prototypes from the full prototype chain get mimicked, you can provide one of the following configuration objects:

  • Array<Object>: a manually assembled array of prototype objects, starting with immediate prototype of obj, and ending with the last ancestral prototype object.
  • PrototypeChainOfObjectConfig: a description object for a slice of continuous prototype chain, used by the function prototypeChainOfObject.
  • true: equivalent to the prototype slice description { start: 0, end: Object.prototype }.
  • false: equivalent to the manually assembled prototype chain [] (empty array).

true

propertyKeys?: Iterable<PropertyKey>

specify additional property keys that should be mirrored.

this would be needed in situations where not all property keys of the given obj are immediately discoverable via Object.getOwnPropertyNames and Object.getOwnPropertySymbols. for instance, dynamically assigned property keys, and class-instance bound keys cannot be deduced beforehand. and so, for such cases, you will need to address those non-discoverable keys in this config option, should you wish for them to be mirrored later on.

[] (empty array)

ignoreKeys?: Iterable<PropertyKey>

specify a set of keys that should not be mirrored.

[] (empty array)

target?: object

specify an optional existing target object on which the provided obj gets mirrored onto.

if none is specified, then a new empty object is used as the target. if a target object is provided, then the same object will be returned by the mirrorObjectThroughComposition function.

{} (new empty object)