Class Redirect<T>

Creates an object which reroutes property accesses (get, set and delete) to other objects.

The keys in Redirect.map are the 'virtual' properties of the Redirect instance and the values are the source objects containing the real properties.

The optional Redirect.remap object may be used to map a virtual property to a property with a different key in the source object. Any virtual properties not in Redirect.remap will naturally have the same key in the source object.

Example

import { redirect } from 'apption'
const obj1 = { a: 1, b: 2 };
const obj2 = { a: 3, b: 4 };
const red = new Redirect({ c: obj1, d: obj2 }, {c: 'a', d: 'a'});
console.log(red.get('c')) // 1
console.log(red.get('d')) // 3

Param: map

Param: remap

Type Parameters

  • T

Constructors

Properties

Methods

Constructors

  • Type Parameters

    • T

    Parameters

    Returns Redirect<T>

Properties

#private: any
map: T
remap?: IOp<ILike<T, IKey>>

Methods

  • Parameters

    • p: IKey

    Returns void

  • Parameters

    • p: IKey

    Returns any

  • Returns T

  • Parameters

    • p: IKey
    • value: any

    Returns void