1.0.14 • Published 7 years ago

funcproxy v1.0.14

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

#Wrapper for Proxy that passes all handler methods to a function

##Install

$ npm install funcproxy

##Requires funcproxy requires a Javascript version that supports the following features:

Proxy
Object.freeze

For example, Node version 6.4 or higher.

##What it does Javascript's Proxy constructor takes two arguments: the target of the proxy and a handler object that can contain methods from the following list:

getPrototypeOf
setPrototypeOf
isExtensible
preventExtension
getOwnPropertyDescriptor
defineProperty
has
get
set
deleteProperty
ownKeys
apply
construct

Each of these functions defines some kind of behavior for the proxy.

The point of funcproxy is to be able to set up a proxy by passing in one general function that can handle any and all of the above handler methods, so that it is not necessary to set up separate handler methods.

##Using funcproxy to create a proxy instance The funcproxy module exports a function. This function takes one argument, an object with setup options, and returns a proxy. The possible options that can be passed in are described in the next section. If no arguments at all are provided to the funcproxy function, the case is treated the same as if an empty object had been passed in.

##Options

  • target - The target of the proxy. If this option is missing, a newly-created object with no properties will be used as the proxy target.
  • isRevocable - Determines whether the proxy will be revocable or not. If this option is missing, it will default to false.
  • func - A function that controls the behavior of the proxy. When any handler method is invoked on the proxy, func is called with one argument, an object that contains the following properties: - method - The handler method. For example, 'set' or 'ownKeys'. - methodArgsArray - An array of the original arguments that the proxy passed into the handler method. - methodArgs - An object that contains the handler method arguments as properties, with appropriate keys. For example, if the handler method is get, the methodArgs object will have the properties 'target', 'property', and 'receiver'. - methodThis - The this value in the handler method. - options - The setup options of this funcproxy instance. These options are frozen and cannot be modified. - proxy - The proxy. - funcproxy - The function exported by the funcproxy module. If the func option is missing, an empty function (a function that does nothing) will be used.
  • methods - The handler methods that will be used by the proxy. This option can be given the following values: true to use all methods, false to use no methods, or a string array of method names to use just those methods. If this option is missing, all methods will be used.
1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago