async-lock
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "async-lock", | ||
"description": "", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "rain1017", | ||
@@ -29,6 +29,6 @@ "private" : false, | ||
"dependencies": { | ||
"q": "~1.1.2", | ||
"lodash": "~3.2.0" | ||
"q": "~1.1.2" | ||
}, | ||
"devDependencies": { | ||
"lodash": "~3.3.0", | ||
"should": "~4.5.0", | ||
@@ -35,0 +35,0 @@ "grunt-cli": "~0.1.13", |
@@ -16,3 +16,3 @@ # async-lock | ||
* @param {String|Array} key resource key or keys to lock | ||
* @param {function} fn async function with node.js style | ||
* @param {function} fn execute function | ||
* @param {function} cb (optional) callback function, otherwise will return a promise | ||
@@ -27,11 +27,26 @@ * @param {Object} opts (optional) options | ||
}, opts); | ||
// Promise mode | ||
lock.acquire(key, function(){ | ||
// return value or promise | ||
}, opts).then(function(){ | ||
// lock released | ||
}); | ||
``` | ||
## Promise mode | ||
## Error Handling | ||
``` | ||
// Callback mode | ||
lock.acquire(key, function(done){ | ||
done(new Error('error')); | ||
}, function(err, ret){ | ||
console.log(err.message) // output: error | ||
}); | ||
// Promise mode | ||
lock.acquire(key, function(){ | ||
// return value or promise | ||
}).then(function(){ | ||
// lock released | ||
throw new Error('error'); | ||
}).catch(function(err){ | ||
console.log(err.message) // output: error | ||
}); | ||
@@ -38,0 +53,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
17168
1
102
10
- Removedlodash@~3.2.0
- Removedlodash@3.2.0(transitive)