Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

proxy-vir

electrovir70.7k(MIT or CC0 1.0)2.0.1TypeScript support: included

An easier Proxy.

proxy, vir, wrapper, object

readme

proxy-vir

Creates a proxy based on multiple dynamically cascaded targets (meaning you can add or remove targets whenever you want) with dynamic proxy handler overriding (meaning you can modify how proxy handlers operate after the proxy has been created).

Installation

npm i proxy-vir

Usages

Simple override

import {createWrappedMultiTargetProxy} from 'proxy-vir';

// something you imported from a 3rd party library that you want to wrap
const importedThing = {
    doThingA() {},
};

const thingWrapper = createWrappedMultiTargetProxy({
    initialTarget: importedThing,
});

// add a new override
thingWrapper.proxyModifier.addOverrideTarget({
    doThingA() {},
});