async-deco
Advanced tools
Comparing version 7.3.0 to 7.4.0
{ | ||
"name": "async-deco", | ||
"version": "7.3.0", | ||
"version": "7.4.0", | ||
"description": "A collection of decorators for adding features to asynchronous functions (callback or promise based).", | ||
@@ -37,2 +37,3 @@ "main": "index.js", | ||
"memoize-cache-utils": "^0.0.2", | ||
"occamsrazor-match": "^2.2.1", | ||
"require-all": "^2.0.0", | ||
@@ -39,0 +40,0 @@ "setimmediate": "^1.0.4", |
@@ -14,2 +14,3 @@ async-deco | ||
* [Proxy](#proxy) | ||
* [Validator](#validator) | ||
* [Fallback](#fallback) | ||
@@ -236,2 +237,28 @@ * [Fallback value](#fallback-value) | ||
Validator | ||
--------- | ||
It uses [occamsrazor-match](https://github.com/sithmel/occamsrazor-match) (or any function) to perform arguments validation. It throws an exception if the validation fail. | ||
It is available in 3 flavours, the usual callback, promise and synchronous. | ||
```js | ||
// var validatorDecorator = require('async-deco/promise/validator'); promise based | ||
// var validatorDecorator = require('async-deco/utils/validator'); synchronous | ||
var validatorDecorator = require('async-deco/callback/validator'); | ||
var validator = validatorDecorator({ name: /[a-zA-Z]/ }, or([false, true])); | ||
var func = validator(function queryUser(user, onlyFirst, cb) { | ||
... | ||
}); | ||
func({ name: 'Bruce Wayne'}, true, function (err, res) { | ||
... this passes the validation | ||
}); | ||
func('Bruce Wayne', true, function (err, res) { | ||
... this returns an error | ||
}); | ||
``` | ||
Fallback | ||
@@ -238,0 +265,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
145893
125
3883
733
8
+ Addedoccamsrazor-match@^2.2.1
+ Addedoccamsrazor-match@2.2.1(transitive)