Creates an object which reroutes property and method accesses 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 { Alias } from 'deleight/proxies/alias'
const obj1 = { a: 1, b: 2 };
const obj2 = { a: 3, b: 4 };
const red = new Alias({ 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

Accessors

Methods

Constructors

Properties

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

Accessors

Methods