async-deco
Advanced tools
Comparing version 3.1.0 to 3.2.0
{ | ||
"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 @@ -------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79999
74
2267
317