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

lockable-storage

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lockable-storage - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

29

LockableStorage.js

@@ -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",

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