Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mutable-proxy with all npm packages installed. Try it out:

var mutableProxy = require("mutable-proxy")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mutable-proxy v1.0.0

A library for creating mutable proxies


Travis-Ci Code Climate Test Coverage

Basic Usage

The factory returns a controller object with functions to affect the mutable state of the proxy

const {
} = mutableProxyFactory();

Set a simple object as target for the proxy

setTarget({ a: 'apple' });
console.log(proxy.a); // => 'apple'
console.log(Object.getPrototypeOf(proxy) === Object.prototype); // => 'true'

Set an array as target for the proxy

setTarget(['a', 'b', 'c']);
console.log(proxy[1]); // => 'b'
console.log(Object.getPrototypeOf(proxy) === Array.prototype);// => 'true'

Set a function as target for the proxy

setTarget(() => 5);
console.log(proxy()); // => '5'
console.log(Object.getPrototypeOf(proxy) === Function.prototype); // => 'true'

Set an object with a custom prototype for the proxy

class Person {
  constructor(name) { = name;
  speak() {
    return `hi, my name is ${}`;

setTarget(new Person('John'));
console.log(proxy.speak()); // => 'hi, my name is John'
console.log(Object.getPrototypeOf(proxy)); // => 'Person {}'


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free