async-lock
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -0,1 +1,10 @@ | ||
1.3.2 | ||
================== | ||
* Handle errors from user-supplied callback better (Thank you @simeonborko) | ||
* Ensure the array parameter does not get mutated for batch acquire (Thank you @taschmidt) | ||
1.3.1 | ||
================== | ||
* Show queue name in errors (thank you @luke-stead-sonocent) | ||
1.3.0 | ||
@@ -2,0 +11,0 @@ ================== |
@@ -136,8 +136,16 @@ 'use strict'; | ||
var called = false; | ||
fn(function (err, ret) { | ||
try { | ||
fn(function (err, ret) { | ||
if (!called) { | ||
called = true; | ||
done(locked, err, ret); | ||
} | ||
}); | ||
} catch (err) { | ||
// catching error thrown in user function fn | ||
if (!called) { | ||
called = true; | ||
done(locked, err, ret); | ||
done(locked, err); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -235,6 +243,5 @@ else { | ||
var fnx = fn; | ||
keys.reverse().forEach(function (key) { | ||
fnx = getFn(key, fnx); | ||
}); | ||
var fnx = keys.reduceRight(function (prev, key) { | ||
return getFn(key, prev); | ||
}, fn); | ||
@@ -241,0 +248,0 @@ if (typeof (cb) === 'function') { |
{ | ||
"name": "async-lock", | ||
"description": "Lock on asynchronous code", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Rogier Schouten", |
@@ -129,3 +129,3 @@ # async-lock | ||
```js | ||
// Specify timeout | ||
// Specify timeout - max amount of time an item can remain in the queue before acquiring the lock | ||
var lock = new AsyncLock({timeout: 5000}); | ||
@@ -136,3 +136,3 @@ lock.acquire(key, fn, function(err, ret) { | ||
// Specify max occupation time | ||
// Specify max occupation time - max amount of time allowed between entering the queue and completing execution | ||
var lock = new AsyncLock({maxOccupationTime: 3000}); | ||
@@ -143,3 +143,3 @@ lock.acquire(key, fn, function(err, ret) { | ||
// Set max pending tasks | ||
// Set max pending tasks - max number of tasks allowed in the queue at a time | ||
var lock = new AsyncLock({maxPending: 1000}); | ||
@@ -146,0 +146,0 @@ lock.acquire(key, fn, function(err, ret) { |
Sorry, the diff of this file is not supported yet
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
17195
261