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

proximify

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proximify

Promisify using ES6 Proxy

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

proximify

Promisify using ES6 Proxy

Like bluebird's promisifyAll, but using ES6 Proxy which enables it to be:

  • Dynamic - lets you add/remove properties
  • Deep - works at any depth

Install

npm i proximify

Usage

Example

import Koa from 'koa';
import http from 'http';
import proximify from 'proximify'

const app = proximify(new Koa());

// Works on properties added later on, and at any depth

app.server = http.createServer(app.callback());
app.server.listenAsync(3000).then(...)


API

proximify(target, options)
  • target [object](required) Object whose methods need to be patched.

  • options [object]:

    • deep [boolean](default:true): If true, applies to child properties recursively

    • store [boolean](default:true): If true, stores the proxy in place of original property (i.e. replaces the original property with its proxy)

    • applyOnData [boolean](default:true): If true, applies to any objects returned (resolved as promise) by the async methods. (equivalent of doing proximify(...) on objects returned from async function)

      const io1 = proximify(new IO(server))
      const io2 = proximify(new IO(server), {applyOnData: false})
      
      const socket1 = io.onceAsync('connection')
      const socket2 = io.onceAsync('connection')
      
      const data1 = socket.onceAsync('test') // works ok
      const data2 = socket.onceAsync('test') // error "onceAsync" undefined
      
    • suffix [string](default:'Async'): Suffix to use to invoke the promisified version of the method.

    • filter [function]: (Not yet implemented)

    • promisifier [function]: (Not yet implemented)

Keywords

promise

FAQs

Package last updated on 06 Apr 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