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

async-chain-proxy

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-chain-proxy

async-chain-proxy enable to call member functions by method chains.

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-42.15%
Maintainers
1
Weekly downloads
 
Created
Source

async-chain-proxy provides method chain interfaces for accessing async methods.

How to use

method chain

class A {
  async foo () {
    console.log('foo')
  }
  async bar () {
    console.log('bar')
  }
}

const chainProxy = require('async-chain-proxy')
const obj = chainProxy(new A())
obj.foo().bar().end()

// output
>foo
>bar

receive a return value

class A {
  async foo () {
    return 'foo'
  }
}
const chainProxy = require('async-chain-proxy')
const obj = chainProxy(new A())
obj.foo().result((v) => console.log(v)).end()

// output
>foo

API

constructor(target, options = {})
options
  • resultFuncName(default: 'result') : If you don't prefer result function name, you can change.
  • endFuncName(default: 'end') : If you don't prefer end function name, you can change.
  • onChainFinished(default: null) : this is a callback function that is called after end().
result(r)

This function is used for receiving result of previous action.

end()

Indicates end of chained actions. If you didn't call end(), all the actions aren't called.

target

Returns target object.

FAQs

Package last updated on 31 Jul 2019

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