function IncrementalIndexedDBAdapter(options) {
      this.mode = "incremental";
      this.options = options || {};
      this.chunkSize = 100;
      this.megachunkCount = this.options.megachunkCount || 24;
      this.lazyCollections = this.options.lazyCollections || [];
      this.idb = null; // will be lazily loaded on first operation that needs it
      this._prevLokiVersionId = null;
      this._prevCollectionVersionIds = {};

      if (!(this.megachunkCount >= 4 && this.megachunkCount % 2 === 0)) {
        throw new Error('megachunkCount must be >=4 and divisible by 2');
      }
    }
An improved Loki persistence adapter for IndexedDB (not compatible with LokiIndexedAdapter)
    Unlike LokiIndexedAdapter, the database is saved not as one big JSON blob, but split into
    small chunks with individual collection documents. When saving, only the chunks with changed
    documents (and database metadata) is saved to IndexedDB. This speeds up small incremental
    saves by an order of magnitude on large (tens of thousands of records) databases. It also
    avoids Safari 13 bug that would cause the database to balloon in size to gigabytes

    The `appname` argument is not provided - to distinguish between multiple app on the same
    domain, simply use a different Loki database name

@example
var adapter = new IncrementalIndexedDBAdapter();

@constructor IncrementalIndexedDBAdapter

@param {object=} options Configuration options for the adapter
@param {function} options.onversionchange Function to call on `IDBDatabase.onversionchange` event
    (most likely database deleted from another browser tab)
@param {function} options.onFetchStart Function to call once IDB load has begun.
    Use this as an opportunity to execute code concurrently while IDB does work on a separate thread
@param {function} options.onDidOverwrite Called when this adapter is forced to overwrite contents
    of IndexedDB. This happens if there's another open tab of the same app that's making changes.
    You might use it as an opportunity to alert user to the potential loss of data
@param {function} options.serializeChunk Called with a chunk (array of Loki documents) before
    it's saved to IndexedDB. You can use it to manually compress on-disk representation
    for faster database loads. Hint: Hand-written conversion of objects to arrays is very
    profitable for performance. If you use this, you must also pass options.deserializeChunk.
@param {function} options.deserializeChunk Called with a chunk serialized with options.serializeChunk
    Expects an array of Loki documents as the return value
@param {number} options.megachunkCount Number of parallel requests for data when loading database.
    Can be tuned for a specific application
@param {array} options.lazyCollections Names of collections that should be deserialized lazily
    Only use this for collections that aren't used at launch