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

async-lock

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-lock - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

6

package.json
{
"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 @@ ```

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