Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

avoidwork/tiny-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-proxy

Tiny Object proxy for Client or Server

build status

API

proxy(obj[, readOnly = false, changeHandler])

Returns a proxy for obj with getters & setters, or only getters if readOnly is true.

Example

const proxy = require('tiny-proxy');
let original = {a: true};
let facade = proxy(original, false, function (key, oldValue, newValue) {
	console.log(key + ' was ' + oldValue + ', and is now ' + newValue);
});

facade.a = false; // a was true, and is now false

Handling changes

Writable proxies will fire the onchange function after applying a change with the key, oldValue & newValue as arguments.

License

Copyright (c) 2016 Jason Mulligan Licensed under the BSD-3 license

About

Tiny Object proxy for Client or Server

Resources

License

Stars

Watchers

Forks

Packages

No packages published