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

async-deco

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-deco - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

callback/proxy.js

2

package.json
{
"name": "async-deco",
"version": "3.1.0",
"version": "3.2.0",
"description": "A collection of decorators for adding features to asynchronous functions (callback or promise based).",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -105,2 +105,19 @@ async-deco

Proxy
-----
It executes a "guard" function before the original one. If it returns an error it will use this error as the return value of the original function.
It is useful if you want to run a function only if it passes some condition (access control).
```js
var proxyDecorator = require('async-deco/callback/proxy');
var proxy = cacheDecorator(function (..., cb) {
// calls cb(errorInstance) if the access is denied
// calls cb() if I can procede calling the function
}, logger);
var myfunc = proxy(function (..., cb) { .... });
```
It takes 2 arguments:
* a guard function [mandatory]. It takes the same arguments of the original function. If it returns an error (using the callback) the original function won't be called.
* a logger function (logs "access denied") [optional]
Fallback

@@ -107,0 +124,0 @@ --------

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