async-lock
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -0,1 +1,5 @@ | ||
0.3.3 / 2015-05-19 | ||
================== | ||
* Bug fix | ||
0.3.2 / 2015-05-08 | ||
@@ -2,0 +6,0 @@ ================== |
@@ -160,4 +160,8 @@ 'use strict'; | ||
AsyncLock.prototype._acquireBatch = function(keys, fn, cb, opts){ | ||
if(typeof(cb) !== 'function'){ | ||
opts = cb; | ||
cb = null; | ||
} | ||
var self = this; | ||
var getFn = function(key, fn){ | ||
@@ -173,3 +177,18 @@ return function(cb){ | ||
}); | ||
fnx(cb); | ||
if(typeof(cb) === 'function'){ | ||
fnx(cb); | ||
} | ||
else{ | ||
var deferred = Promise.defer(); | ||
fnx(function(err, ret){ | ||
if(err){ | ||
deferred.reject(err); | ||
} | ||
else{ | ||
deferred.resolve(ret); | ||
} | ||
}); | ||
return deferred.promise; | ||
} | ||
}; | ||
@@ -176,0 +195,0 @@ |
{ | ||
"name": "async-lock", | ||
"description": "", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"author": "rain1017", | ||
@@ -6,0 +6,0 @@ "private" : false, |
@@ -148,8 +148,26 @@ 'use strict'; | ||
}); | ||
})).then(function(){ | ||
})) | ||
.then(function(){ | ||
assert(value === concurrency); | ||
done(); | ||
}, function(err){ | ||
done(err); | ||
}); | ||
}) | ||
.then(function(){ | ||
var key1 = false, key2 = false; | ||
lock.acquire('key1', function(){ | ||
key1 = true; | ||
return Q.delay(20).then(function(){ | ||
key1 = false; | ||
}); | ||
}); | ||
lock.acquire('key2', function(){ | ||
key2 = true; | ||
return Q.delay(10).then(function(){ | ||
key2 = false; | ||
}); | ||
}); | ||
return lock.acquire(['key1', 'key2'], function(){ | ||
assert(key1 === false && key2 === false); | ||
}); | ||
}) | ||
.nodeify(done); | ||
}); | ||
@@ -156,0 +174,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
20588
470