Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unwrappable-proxy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unwrappable-proxy

An extension of ES6's revocable Proxy objects that also returns the target object to allow for easy unwrapping

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

unwrappable-proxy

unwrappable-proxy is a short utility for making proxies that are easy to unwrap. It acts as an extension* of Proxy.revocable that returns the target object on revoke in order to make returning to the original object easier.

Usage

const uProxy = require("unwrappable-proxy");

let base = { foo: 0 };
let unwrappable = uProxy(base, {
	get(target, field) {
		return target[field] + 1;
	},
	set(target, field, value) {
		target[field] = value * 10;
	}
});

console.log(unwrappable.proxy.foo); // 1
unwrappable.proxy.foo = 2;
console.log(base.foo); // 20
console.log(unwrappable.proxy.foo); // 21

let obj = unwrappable.revoke();

console.log(obj === base); // true
console.log(unwrappable.proxy.foo); // TypeError: Cannot perform 'get' on a proxy that has been revoked

Keywords

FAQs

Package last updated on 16 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc