New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

atomize-server

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomize-server - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

90

lib/atomize-server.js

@@ -43,3 +43,4 @@ /*global require, exports */

function TVar(id, isArray, raw) {
function TVar(id, isArray, raw, creator) {
this.creator = creator;
this.raw = isArray ? [] : {};

@@ -57,3 +58,3 @@ util.shallowCopy(raw, this.raw);

bump: function () {
bump: function (future) {
var i, observers;

@@ -67,3 +68,3 @@ // create a fresh observers array otherwise, if on the

for (i = 0; i < observers.length; i += 1) {
(observers[i])(this);
(observers[i])(this, future);
}

@@ -73,6 +74,6 @@ }

TVar.create = function (isArray, value) {
TVar.create = function (isArray, value, creator) {
var globalTVar;
globalTVarCount += 1;
globalTVar = new TVar(globalTVarCount, isArray, value);
globalTVar = new TVar(globalTVarCount, isArray, value, creator);
globalTVars[globalTVar.id] = globalTVar;

@@ -82,2 +83,25 @@ return globalTVar;

function CoalescingObserver() {
this.map = new cereal.Map();
this.keys = [];
}
CoalescingObserver.prototype = {
insert: function (key, value) {
if (!this.map.has(key)) {
this.keys.push(key);
}
this.map.set(key, value);
},
force: function () {
var i, key;
for (i = 0; i < this.keys.length; i += 1) {
key = this.keys[i];
(this.map.get(key))();
}
this.keys = [];
this.map = new cereal.Map();
}
}
function Client(connection, serverEventEmitter) {

@@ -114,2 +138,3 @@ this.emitter = new events.EventEmitter();

this.emit('close', this);
delete globalLocal[this.connection.id];
},

@@ -149,3 +174,3 @@

globalTVar = TVar.create(localTVar.isArray, localTVar.value);
globalTVar = TVar.create(localTVar.isArray, localTVar.value, this);
this.localGlobal[localTVar.id] = globalTVar.id;

@@ -158,9 +183,9 @@ this.globalLocal[globalTVar.id] = localTVar.id;

checkReads: function (txnLog, updates) {
checkThing: function (thing, updates) {
var keys, i, ok, localTVar, globalTVar;
ok = true;
keys = Object.keys(txnLog.read);
keys = Object.keys(thing);
for (i = 0; i < keys.length; i += 1) {
localTVar = txnLog.read[keys[i]];
localTVar = thing[keys[i]];
localTVar.id = keys[i];

@@ -177,18 +202,8 @@ globalTVar = globalTVars[this.localGlobal[localTVar.id]];

checkReads: function (txnLog, updates) {
return this.checkThing(txnLog.read, updates);
},
checkWrites: function (txnLog, updates) {
var keys, i, ok, localTVar, globalTVar;
ok = true;
keys = Object.keys(txnLog.written);
for (i = 0; i < keys.length; i += 1) {
localTVar = txnLog.written[keys[i]];
localTVar.id = keys[i];
globalTVar = globalTVars[this.localGlobal[localTVar.id]];
if (localTVar.version !== globalTVar.version) {
updates[globalTVar.id] = true;
ok = false;
}
}
return ok;
return this.checkThing(txnLog.written, updates);
},

@@ -207,9 +222,13 @@

fired = false;
observer = function (globalTVar) {
if (! fired) {
fired = true;
updates[globalTVar.id] = true;
self.write(self.createUpdates(updates, txnId));
self.write({type: "retry", txnId: txnId});
}
observer = function (globalTVar, future) {
updates[globalTVar.id] = true;
future.insert(
updates,
function () {
if (!fired) {
fired = true;
self.write(self.createUpdates(updates, txnId));
self.write({type: "retry", txnId: txnId});
}
});
};

@@ -234,3 +253,3 @@

commit: function (txnLog) {
var txnId, ok, i, j, keys, localTVar, globalTVar, names, name, value, updates, key;
var txnId, ok, i, j, keys, localTVar, globalTVar, names, name, value, updates, key, future;

@@ -264,2 +283,4 @@ txnId = txnLog.txnId;

future = new CoalescingObserver();
keys = Object.keys(txnLog.written);

@@ -289,5 +310,6 @@ for (i = 0; i < keys.length; i += 1) {

}
globalTVar.bump();
globalTVar.bump(future);
}
future.force();
} else {

@@ -384,3 +406,3 @@ this.write(this.createUpdates(updates, txnId));

globalTVarCount = 1;
rootTVar = new TVar(globalTVarCount, Array.isArray(root), root);
rootTVar = new TVar(globalTVarCount, Array.isArray(root), root, undefined);
globalTVars[rootTVar.id] = rootTVar;

@@ -387,0 +409,0 @@ rootTVar.bump(); // Need 2 bumps to ensure we're ahead of any clients.

{
"name": "atomize-server",
"author": "Matthew Sackman",
"version": "0.0.5",
"version": "0.0.6",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

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