lockable-storage
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -19,11 +19,8 @@ /** | ||
/* | ||
LockableStorage.lock(key, lockAquiredCallback) | ||
*/ | ||
var LockableStorage, | ||
myId, | ||
randomNumber = function () { | ||
return Math.random() * 1000000000 | 0; | ||
}, | ||
uniqueId = Date.now() + ":" + randomNumber(); | ||
STRETCH_CRITICAL_SECTION_UPPER_BOUND = 1.50; | ||
module.exports = LockableStorage = { | ||
@@ -40,8 +37,2 @@ | ||
function someNumber() { | ||
return Math.random() * 1000000000 | 0; | ||
} | ||
myId = Date.now() + ":" + someNumber(); | ||
function getter(lskey) { | ||
@@ -54,3 +45,3 @@ return function () { | ||
var splitted = value.split(/\|/); | ||
if (parseInt(splitted[1]) < now()) { | ||
if (parseInt(splitted[1]) < Date.now()) { | ||
return null; | ||
@@ -75,3 +66,3 @@ } | ||
localStorage[xKey] = myId; | ||
localStorage[xKey] = uniqueId; | ||
if (getY()) { | ||
@@ -82,8 +73,8 @@ if (!synchronous) | ||
} | ||
localStorage[yKey] = myId + "|" + (now() + 40); | ||
localStorage[yKey] = uniqueId + "|" + (Date.now() + 40); | ||
if (localStorage[xKey] !== myId) { | ||
if (localStorage[xKey] !== uniqueId) { | ||
if (!synchronous) { | ||
setTimeout(function () { | ||
if (getY() !== myId) { | ||
if (getY() !== uniqueId) { | ||
setTimeout(function () { _mutexTransaction(key, callback); }, 0); | ||
@@ -108,3 +99,3 @@ } else { | ||
getMutex = getter(mutexKey), | ||
mutexValue = myId + ":" + someNumber() + "|" + (now() + maxDuration); | ||
mutexValue = uniqueId + ":" + randomNumber() + "|" + (Date.now() + maxDuration); | ||
@@ -111,0 +102,0 @@ function restart () { |
{ | ||
"name": "lockable-storage", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Concurrency and locking for HTML5 localStorage", | ||
@@ -5,0 +5,0 @@ "main": "LockableStorage.js", |
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
6868
129