New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

class-proxy

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-proxy

The Class Proxy is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
decreased by-15.39%
Maintainers
1
Weekly downloads
 
Created
Source

class-proxy

The Class Proxy is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).

npm install class-proxy

api

  • MDN: Proxy
  • index.d.ts

demo

import createClassProxy from 'class-proxy';
import { createClassProxy } from 'class-proxy';

var createClassProxy = require("class-proxy/node");
import { implementation as URLImpl } from 'whatwg-url/lib/URL-impl';

let URLImplProxy2 = createClassProxy(URLImpl, {
	get(target, name)
	{
		return target[name];
	},
	set(target, prop, value, receiver)
	{
		if (prop == '_query')
		{
			value._url = target;

			console.log(value);
		}

		target[prop] = value;
		return true;
	},
	ownKeys(target): string[]
	{
		return [
			'href',
			'origin',
			'protocol',
			'username',
			'password',
			'host',
			'hostname',
			'port',
			'pathname',
			'search',
			'hash',
			'searchParams',
		];
	},
	getOwnPropertyDescriptor(target, prop)
	{
		return {
			value: target[prop],
			enumerable: this.ownKeys(target).includes(prop),
			configurable: true,
		};
	},
	construct(target, args)
	{
		if (typeof args[0] == 'string')
		{
			return new target([args[0]]);
		}

		return new target(...args);
	}
});

Keywords

FAQs

Package last updated on 15 Oct 2022

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