@nozbe/lokijs
Advanced tools
Comparing version 1.5.10-wmelon1 to 1.5.10-wmelon2
{ | ||
"name": "@nozbe/lokijs", | ||
"version": "1.5.10-wmelon1", | ||
"version": "1.5.10-wmelon2", | ||
"description": "Nozbe's temporary fork of LokiJS - used for WatermelonDB purposes to work around NPM issues", | ||
@@ -5,0 +5,0 @@ "homepage": "https://techfort.github.io/LokiJS/", |
@@ -16,2 +16,5 @@ (function(root, factory) { | ||
/* jshint -W030 */ | ||
var DEBUG = typeof window !== 'undefined' && !!window.__loki_incremental_idb_debug; | ||
/** | ||
@@ -59,2 +62,3 @@ * An improved Loki persistence adapter for IndexedDB (not compatible with LokiIndexedAdapter) | ||
// use idIndex to find first collection.data position within the $loki range | ||
collection.ensureId(); | ||
var idIndex = collection.idIndex; | ||
@@ -139,4 +143,4 @@ | ||
var that = this; | ||
console.log("exportDatabase - begin"); | ||
console.time("exportDatabase"); | ||
DEBUG && console.log("exportDatabase - begin"); | ||
DEBUG && console.time("exportDatabase"); | ||
@@ -162,2 +166,3 @@ var chunksToSave = []; | ||
// we must stringify now, because IDB is asynchronous, and underlying objects are mutable | ||
// (and it's faster for some reason) | ||
chunkData = JSON.stringify(chunkData); | ||
@@ -169,3 +174,3 @@ savedLength += chunkData.length; | ||
}); | ||
} | ||
}; | ||
dirtyChunks.forEach(prepareChunk); | ||
@@ -175,4 +180,3 @@ | ||
if (collection.dirty) { | ||
// this is recreated on load anyway, so we can make metadata smaller | ||
collection.idIndex = []; | ||
collection.idIndex = []; // this is recreated lazily | ||
collection.data = []; | ||
@@ -199,3 +203,3 @@ | ||
console.log(`[Loki] Saving ${savedLength} bytes(ish) to DB`); | ||
DEBUG && console.log("saved size: " + savedLength); | ||
that._saveChunks(dbname, chunksToSave, callback); | ||
@@ -221,8 +225,8 @@ }; | ||
var that = this; | ||
console.log("loadDatabase - begin"); | ||
console.time("loadDatabase"); | ||
DEBUG && console.log("loadDatabase - begin"); | ||
DEBUG && console.time("loadDatabase"); | ||
this._getAllChunks(dbname, function(chunks) { | ||
if (!Array.isArray(chunks)) { | ||
// we got an error | ||
console.timeEnd("loadDatabase"); | ||
DEBUG && console.timeEnd("loadDatabase"); | ||
callback(chunks); | ||
@@ -232,3 +236,3 @@ } | ||
if (!chunks.length) { | ||
console.timeEnd("loadDatabase"); | ||
DEBUG && console.timeEnd("loadDatabase"); | ||
callback(null); | ||
@@ -238,3 +242,3 @@ return; | ||
console.log("Found chunks:", chunks.length); | ||
DEBUG && console.log("Found chunks:", chunks.length); | ||
@@ -293,3 +297,3 @@ that._sortChunksInPlace(chunks); | ||
console.timeEnd("loadDatabase"); | ||
DEBUG && console.timeEnd("loadDatabase"); | ||
callback(loki); | ||
@@ -354,3 +358,3 @@ }); | ||
var that = this; | ||
console.log("initializing idb"); | ||
DEBUG && console.log("initializing idb"); | ||
@@ -366,3 +370,3 @@ if (this.idbInitInProgress) { | ||
var db = e.target.result; | ||
console.log('onupgradeneeded, old version: ' + e.oldVersion); | ||
DEBUG && console.log('onupgradeneeded, old version: ' + e.oldVersion); | ||
@@ -389,6 +393,6 @@ if (e.oldVersion < 1) { | ||
console.log("init success"); | ||
DEBUG && console.log("init success"); | ||
that.idb.onversionchange = function(versionChangeEvent) { | ||
console.log('IDB version change', versionChangeEvent); | ||
DEBUG && console.log('IDB version change', versionChangeEvent); | ||
// This function will be called if another connection changed DB version | ||
@@ -439,3 +443,3 @@ // (Most likely database was deleted from another browser tab, unless there's a new version | ||
that.operationInProgress = false; | ||
console.timeEnd("exportDatabase"); | ||
DEBUG && console.timeEnd("exportDatabase"); | ||
callback(); | ||
@@ -517,4 +521,4 @@ }; | ||
var that = this; | ||
console.log("deleteDatabase - begin"); | ||
console.time("deleteDatabase"); | ||
DEBUG && console.log("deleteDatabase - begin"); | ||
DEBUG && console.time("deleteDatabase"); | ||
@@ -530,3 +534,3 @@ if (this.idb) { | ||
that.operationInProgress = false; | ||
console.timeEnd("deleteDatabase"); | ||
DEBUG && console.timeEnd("deleteDatabase"); | ||
callback({ success: true }); | ||
@@ -533,0 +537,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
3060272
9738