async-lock
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -1,5 +0,9 @@ | ||
1.2.7 | ||
1.2.8 | ||
================== | ||
* Fix #37 process not set when acquiring lock (Thank you @Philipp91) | ||
1.2.7 | ||
================== | ||
DO NOT USE, erroneous publish | ||
1.2.6 | ||
@@ -6,0 +10,0 @@ ================== |
@@ -12,7 +12,13 @@ 'use strict'; | ||
// domain of current running func {key : fn} | ||
this.domains = Object.create(null); | ||
// lock is reentrant for same domain | ||
this.domainReentrant = opts.domainReentrant || false; | ||
if (this.domainReentrant) { | ||
if (typeof process === 'undefined' || typeof process.domain === 'undefined') { | ||
throw new Error( | ||
'Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, ' + | ||
'use a NodeJS version that still implements Domain, or install a browser polyfill.'); | ||
} | ||
// domain of current running func {key : fn} | ||
this.domains = Object.create(null); | ||
} | ||
@@ -74,3 +80,5 @@ this.timeout = opts.timeout || AsyncLock.DEFAULT_TIMEOUT; | ||
} | ||
delete self.domains[key]; | ||
if (self.domainReentrant) { | ||
delete self.domains[key]; | ||
} | ||
} | ||
@@ -114,3 +122,3 @@ | ||
if (locked) { | ||
if (self.domainReentrant && locked) { | ||
self.domains[key] = process.domain; | ||
@@ -141,3 +149,3 @@ } | ||
}; | ||
if (!!process.domain) { | ||
if (self.domainReentrant && !!process.domain) { | ||
exec = process.domain.bind(exec); | ||
@@ -144,0 +152,0 @@ } |
{ | ||
"name": "async-lock", | ||
"description": "Lock on asynchronous code", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Rogier Schouten", |
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
15345
239