New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ezp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ezp

Easy Proxy for fluent APIs

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ezp

Easy Proxy for fluent APIs.

Use

const ezp = require('ezp');

const P = ezp({
    get: function(props) {
        // Called by:
        //      P.foo.bar.baz.$
        // props:
        //      ['foo', 'bar', 'baz']
    },
    set: function(props, value) {
        // Called by:
        //      P.foo.bar.baz = 1337
        // props:
        //      ['foo', 'bar', 'baz']
        // value:
        //      1337
    },
    delete: function(props) {
        // Called by:
        //      delete P.foo.bar.baz;
        // props:
        //      ['foo', 'bar', 'baz']
    },
    has: function(props) {
        // Called by:
        //      'qux' in P.foo.bar.baz
        // props:
        //      ['foo', 'bar', 'baz']
        // value:
        //      'qux'
    },
    apply: function(props, args) {
        // Called by:
        //      P.foo.bar.baz(1337, 'qux')
        // props:
        //      ['foo', 'bar', 'baz']
        // args:
        //      [1337, 'qux']
    },
}, '$');

ezp receives a handler object and an optional escape property, and returns a fluent proxy.

The handler object supports the following fluent traps: get, set, delete, in and apply, which are triggered as illustrated in the example above.

Note that to use the get trap, an escape property must be provided. This value will then be magical, and be used to trigger the get trap instead of navigating one level deeper within the proxy itself.

NOTE: The proxy is created as a virtual object, and interacting with the underlying target without setting the appropriate traps may result in unspecified behaviour. Use only the proxy in ways which are handled by the traps provided.

Install

with npm do:

npm install ezp

License

MIT

Keywords

proxy

FAQs

Package last updated on 07 Oct 2018

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