Socket
Socket
Sign inDemoInstall

dexie

Package Overview
Dependencies
Maintainers
2
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexie - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

.idea/.name

52

addons/Dexie.Observable/Dexie.Observable.js

@@ -1,2 +0,2 @@

/// <reference path="../../src/Dexie.js" />
/// <reference path="../../src/Dexie.js" />
/*

@@ -23,3 +23,3 @@ * Disclaimber: This addon is in alpha status meaning that

mods: Object, // UPDATE: mods contains the modifications made to the object.
oldObj: Object, // DELETE: oldObj contains the object deleted. UPDATE: oldObj contains the old object before updates applied.
oldObj: Object // DELETE: oldObj contains the object deleted. UPDATE: oldObj contains the old object before updates applied.
});

@@ -114,3 +114,3 @@

stores["_changes"] = "++rev";
stores["_syncNodes"] = "++id,myRevision,lastHeartBeat,url,isMaster,type,status";
stores["_syncNodes"] = "++id,myRevision,lastHeartBeat,&url,isMaster,type,status";
stores["_intercomm"] = "++id,destinationNode";

@@ -123,3 +123,3 @@ stores["_uncommittedChanges"] = "++id,node"; // For remote syncing when server returns a partial result.

var schema = dbSchema[tableName];
if (schema.primKey.name.indexOf('$$') == 0) {
if (schema.primKey.name.indexOf('$$') === 0) {
schema.primKey.uuid = true;

@@ -133,3 +133,3 @@ schema.primKey.name = schema.primKey.name.substr(2);

// Marked observable tables with "observable" in their TableSchema.
if (tableName.indexOf('_') != 0 && tableName.indexOf('$') != 0) {
if (tableName.indexOf('_') !== 0 && tableName.indexOf('$') !== 0) {
dbSchema[tableName].observable = true;

@@ -154,3 +154,3 @@ }

return table;
}
};
});

@@ -211,3 +211,3 @@

return trans;
}
};
});

@@ -262,3 +262,3 @@

return origClose.apply(this, arguments);
}
};
});

@@ -274,3 +274,3 @@

});
}
};
});

@@ -347,3 +347,3 @@

});
}
};
});

@@ -363,3 +363,3 @@ }

deleteTimeStamp: null,
isMaster: 0,
isMaster: 0
});

@@ -426,3 +426,3 @@ if (Dexie.Observable.latestRevision[db.name] < latestRevision) {

var lastChange = changes[changes.length - 1];
partial = (changes.length == 1000); // Same as limit.
partial = (changes.length === 1000); // Same as limit.
// Let all objects pass through the READING hook before notifying our listeners:

@@ -501,3 +501,3 @@ changes.forEach(function (change) {

var weBecameMaster = false;
db._syncNodes.where("lastHeartBeat").below(Date.now() - NODE_TIMEOUT).and(function (node) { return node.type === 'local' }).modify(function (node) {
db._syncNodes.where("lastHeartBeat").below(Date.now() - NODE_TIMEOUT).and(function (node) { return node.type === 'local'; }).modify(function (node) {
if (node.deleteTimeStamp && node.deleteTimeStamp < Date.now()) {

@@ -614,3 +614,3 @@ // Delete the node.

});
}
};

@@ -621,7 +621,7 @@ db.broadcastMessage = function (type, message, bIncludeSelf) {

db._syncNodes.each(function (node) {
if (node.type == 'local' && (bIncludeSelf || node.id !== mySyncNodeId)) {
if (node.type === 'local' && (bIncludeSelf || node.id !== mySyncNodeId)) {
db.sendMessage(type, message, node.id);
}
});
}
};

@@ -659,6 +659,6 @@ db.observable = {};

db.sendMessage('response', { result: result }, msg.sender, { requestId: msg.id });
}
};
msg.reject = function (error) {
db.sendMessage('response', { error: error.toString() }, msg.sender, { isFailure: true, requestId: msg.id });
}
};
var message = msg.message;

@@ -688,3 +688,3 @@ delete msg.message;

var args = arguments;
setTimeout(function () { fn.apply(this, [].slice.call(args, 1)) }, 0);// If not FF13 and earlier failed, we could use this call here instead: setTimeout.call(this, [fn, 0].concat(arguments));
setTimeout(function () { fn.apply(this, [].slice.call(args, 1)); }, 0);// If not FF13 and earlier failed, we could use this call here instead: setTimeout.call(this, [fn, 0].concat(arguments));
} : setImmediate;

@@ -698,3 +698,3 @@

var res = f1.apply(this, arguments);
if (res && typeof res.then == 'function') {
if (res && typeof res.then === 'function') {
var thiz = this, args = arguments;

@@ -706,3 +706,3 @@ return res.then(function () {

return f2.apply(this, arguments);
}
};
}

@@ -722,6 +722,6 @@

d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
return (c === 'x' ? r : (r & 0x7 | 0x8)).toString(16);
});
return uuid;
}
};

@@ -753,7 +753,7 @@ Dexie.Observable._onStorage = function onStorage(event) {

}
}
};
Dexie.Observable._onBeforeUnload = function () {
Dexie.Observable.on.beforeunload.fire();
}
};

@@ -768,3 +768,3 @@ Dexie.Observable.localStorageImpl = window.localStorage;

}).apply(this, typeof module === 'undefined' || (typeof window !== 'undefined' && this == window)
}).apply(this, typeof module === 'undefined' || (typeof window !== 'undefined' && this === window)
? [window, function (name, value) { window[name] = value; }, true ] // Adapt to browser environment

@@ -771,0 +771,0 @@ : [global, function (name, value) { module.exports = value; }, false]); // Adapt to Node.js environment

@@ -0,0 +0,0 @@ ///<reference path="../../src/Dexie.js" />

@@ -1,2 +0,2 @@

/// <reference path="../../../src/Dexie.js" />
/// <reference path="../../../src/Dexie.js" />
/// <reference path="../Dexie.Observable/Dexie.Observable.js" />

@@ -32,8 +32,8 @@ /// <reference path="Dexie.Syncable.SyncProtocolAPI.js" />

Dexie.vip(function () {
if (msg.type == 'connect') {
if (msg.type === 'connect') {
// We are master node and another non-master node wants us to do the connect.
db.syncable.connect(msg.protocolName, msg.url, msg.options).then(msg.resolve, msg.reject);
} else if (msg.type == 'disconnect') {
} else if (msg.type === 'disconnect') {
db.syncable.disconnect(msg.url).then(msg.resolve, msg.reject);
} else if (msg.type == 'syncStatusChanged') {
} else if (msg.type === 'syncStatusChanged') {
// We are client and a master node informs us about syncStatus change.

@@ -97,3 +97,3 @@ // Lookup the connectedProvider and call its event

}
}
};

@@ -104,3 +104,3 @@ db.syncable.list = function () {

});
}
};

@@ -111,3 +111,3 @@ db.syncable.on = Dexie.events(db, { statusChanged: "asap" });

if (db._localSyncNode && db._localSyncNode.isMaster) {
activePeers.filter(function (peer) { return peer.url === url }).forEach(function (peer) {
activePeers.filter(function (peer) { return peer.url === url; }).forEach(function (peer) {
peer.disconnect(Statuses.OFFLINE);

@@ -120,7 +120,7 @@ });

}
//return db._syncNodes.where("type").equals("remote").and(function (node) { return node.url == url }).modify(function (node) {
return db._syncNodes.where("url").equals(url).modify(function (node) {
node.status = Statuses.OFFLINE;
});
}
};

@@ -165,3 +165,3 @@ db.syncable.connect = function (protocolName, url, options) {

}
}
};

@@ -173,12 +173,15 @@ db.syncable.delete = function (url) {

// Find the node
db._syncNodes.where("url").equals(url).first(function(node) {
// If not found, resolve here (nothing deleted), else continue the promise chain and
// delete the node and all that refers to it...
if (!node) {
return;
} else {
var nodeId = node.id;
// Delete the node
return db._syncNodes.delete(nodeId).then(function() {
// When this node is gone, let's clear the _changes table by
db._syncNodes.where("url").equals(url).toArray(function (nodes) {
// If it's found (or even several found, as detected by @martindiphoorn),
// let's delete it (or them) and cleanup _changes and _uncommittedChanges
// accordingly.
if (nodes.length > 0) {
var nodeIDs = nodes.map(function (node) { return node.id; });
// The following 'return' statement is not needed right now, but I leave it
// there because if we would like to add a 'then()' statement to the main ,
// operation above ( db._syncNodes.where("url").equals(url).toArray(...) ) ,
// this return statement will asure that the whole chain is waited for
// before entering the then() callback.
return db._syncNodes.where('id').anyOf(nodeIDs).delete().then(function() {
// When theese nodes are gone, let's clear the _changes table
// from all revisions older than the oldest node.

@@ -193,3 +196,3 @@ // First check which is the currenly oldest node, now when we have deleted

// Also don't forget to delete all uncommittedChanges for the deleted node:
return db._uncommittedChanges.where('node').equals(nodeId).delete();
return db._uncommittedChanges.where('node').anyOf(nodeIDs).delete();
});

@@ -209,3 +212,3 @@ }

/// <param name="protocolInstance" type="ISyncProtocol"></param>
var existingPeer = activePeers.filter(function (peer) { return peer.url == url; });
var existingPeer = activePeers.filter(function (peer) { return peer.url === url; });
if (existingPeer.length > 0) {

@@ -290,3 +293,3 @@ // Never create multiple syncNodes with same protocolName and url. Instead, let the next call to connect() return the same promise that

//return db._syncNodes.update(this.nodeID, { syncContext: this });
}
};

@@ -302,3 +305,3 @@ return node; // returning node will make the db.transaction()-promise resolve with this value.

function changeStatusTo(newStatus) {
if (node.status != newStatus) {
if (node.status !== newStatus) {
node.status = newStatus;

@@ -330,3 +333,3 @@ node.save();

reject(err);
}
};
Dexie.asap(function () {

@@ -407,3 +410,3 @@ try {

remoteBaseRevision: node.remoteBaseRevisions[i].remote
}
};
}

@@ -420,3 +423,3 @@ }

return getLocalChangesForNode(node, function autoAck (changes, remoteBaseRevision, partial, nodeModificationsOnAck) {
if (changes.length === 0 && 'myRevision' in nodeModificationsOnAck && nodeModificationsOnAck.myRevision != node.myRevision) {
if (changes.length === 0 && 'myRevision' in nodeModificationsOnAck && nodeModificationsOnAck.myRevision !== node.myRevision) {
Object.keys(nodeModificationsOnAck).forEach(function (keyPath) {

@@ -450,3 +453,3 @@ Dexie.setByKeyPath(node, keyPath, nodeModificationsOnAck[keyPath]);

// Check if we're in the middle of already doing that:
if (node.dbUploadState == null) {
if (node.dbUploadState === null) {
// Initiatalize dbUploadState

@@ -489,3 +492,3 @@ var tablesToUpload = db.tables.filter(function (table) { return table.schema.observable; }).map(function (table) { return table.name; });

key: cursor.key,
obj: cursor.value,
obj: cursor.value
});

@@ -500,3 +503,3 @@ state.currentKey = cursor.key;

// Done iterating this table. Check if there are more tables to go through:
if (state.tablesToUpload.length == 0) {
if (state.tablesToUpload.length === 0) {
// Done iterating all tables

@@ -527,3 +530,3 @@ // Now append changes occurred during our dbUpload:

return db.transaction('r', db._changes, function () {
var query = (maxRevision == Infinity ?
var query = (maxRevision === Infinity ?
db._changes.where('rev').above(revision) :

@@ -546,5 +549,5 @@ db._changes.where('rev').between(revision, maxRevision, false, true));

};
if (change.type == CREATE)
if (change.type === CREATE)
changeToSend.obj = change.obj;
else if (change.type == UPDATE)
else if (change.type === UPDATE)
changeToSend.mods = change.mods;

@@ -634,3 +637,3 @@

// 1. Open a write transaction on all tables in DB
return db.transaction('rw', db.tables.filter(function (table) { return table.name == '_changes' || table.name == '_uncommittedChanges' || table.schema.observable }), function () {
return db.transaction('rw', db.tables.filter(function (table) { return table.name === '_changes' || table.name === '_uncommittedChanges' || table.schema.observable; }), function () {
var trans = Dexie.currentTransaction;

@@ -905,3 +908,3 @@ var localRevisionBeforeChanges = 0;

return origClose.apply(this, arguments);
}
};
});

@@ -915,3 +918,3 @@

});
}
};

@@ -950,3 +953,3 @@ function enque(context, fn, instanceID) {

}
}
};

@@ -968,3 +971,3 @@

var hadParentPath = false;
Object.keys(prevChange.mods).filter(function (parentPath) { return keyPath.indexOf(parentPath + '.') === 0 }).forEach(function (parentPath) {
Object.keys(prevChange.mods).filter(function (parentPath) { return keyPath.indexOf(parentPath + '.') === 0; }).forEach(function (parentPath) {
setByKeyPath(clonedChange[parentPath], keyPath.substr(parentPath.length + 1), nextChange.mods[keyPath]);

@@ -979,3 +982,3 @@ hadParentPath = true;

// we must mimic what would happen if applying the two changes after each other:
Object.keys(prevChange.mods).filter(function (subPath) { return subPath.indexOf(keyPath + '.') === 0 }).forEach(function (subPath) {
Object.keys(prevChange.mods).filter(function (subPath) { return subPath.indexOf(keyPath + '.') === 0; }).forEach(function (subPath) {
delete clonedChange[subPath];

@@ -993,3 +996,3 @@ });

SYNCING: 3, // Syncing with server. For poll pattern, this is every poll call. For react pattern, this is when local changes are being sent to server.
ERROR_WILL_RETRY: 4, // An error occured such as net down but the sync provider will retry to connect.
ERROR_WILL_RETRY: 4 // An error occured such as net down but the sync provider will retry to connect.
};

@@ -1004,3 +1007,3 @@

"4": "ERROR_WILL_RETRY"
}
};

@@ -1016,3 +1019,3 @@ Dexie.Syncable.registeredProtocols = {}; // Map<String,ISyncProviderFactory> when key is the provider name.

Dexie.Syncable.registeredProtocols[name] = protocolInstance;
}
};

@@ -1022,4 +1025,4 @@ // Finally, add this addon to Dexie:

}).apply(this, typeof module === 'undefined' || (typeof window !== 'undefined' && this == window)
}).apply(this, typeof module === 'undefined' || (typeof window !== 'undefined' && this === window)
? [window, function (name, value) { window[name] = value; }, true] // Adapt to browser environment
: [global, function (name, value) { module.exports = value; }, false]); // Adapt to Node.js environment

@@ -0,0 +0,0 @@ /* SyncProtocol API - an independant syncronization API used by Dexie.Syncable.js.

@@ -0,0 +0,0 @@ ///<reference path="test-syncable.html" />

@@ -0,0 +0,0 @@ ///<reference path="test-syncable.html" />

@@ -0,0 +0,0 @@ ///<reference path="test-syncable.html" />

@@ -0,0 +0,0 @@ {

{
"name": "dexie",
"version": "1.0.2",
"version": "1.0.3",
"description": "Minimalistic IndexedDB API with bullet proof transactions",

@@ -5,0 +5,0 @@ "main": "src/Dexie.js",

Dexie.js
========
[![NPM Version][npm-image]][npm-url]
A bullet proof indexedDB wrapper.

@@ -50,2 +53,5 @@

[npm-image]: https://img.shields.io/npm/v/dexie.svg?style=flat
[npm-url]: https://npmjs.org/package/dexie

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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