lib/localPersistence/localPersistenceManager.js
/**
   * Initialize or load the disk level and the level copied into memory.
   *
   * @param {string} sublevel the level key
   * @param {options} options the sublevel options. Just when initializing a new level.
   * @returns an array with two copies of the same level, one on disk and one in memory.
   *
   * @public
   */
Initialize or load the disk level and the level copied into memory.
@param {string} sublevel the level key
@param {options} options the sublevel options. Just when initializing a new level.
@returns an array with two copies of the same level, one on disk and one in memory.

@public
Initialize or load the disk level and the level copied into memory . @param { string } sublevel the level key @param { options } options the sublevel options . Just when initializing a new level . @returns an array with two copies of the same level one on disk and one in memory . @public
async initializeLevel(sublevel, options = DEFAULT_GET_OPTIONS) {
    if (sublevel === 'managementLevel') {
      throw new Error('Reserved level');
    }
    try {
      const tmpOptions = await this.managementLevel.get(sublevel);
      let memorySubLevel = null;
      if (this.readInMemory) {
        memorySubLevel = this.memoryLevels.get(sublevel);
      }
      const diskSubLevel = subleveldown(this.db, sublevel, tmpOptions);
      return [diskSubLevel, memorySubLevel];
    } catch (error) {
      if (!options) {
        throw new Error(error.message);
      }
      const diskSublevel = subleveldown(this.db, sublevel, options);
      await this.managementLevel.put(sublevel, options);
      let memorySubLevel = null;
      if (this.readInMemory) {
        memorySubLevel = levelup(encodedown(memdown(), options));
        this.memoryLevels.set(sublevel, memorySubLevel);
      }
      return [diskSublevel, memorySubLevel];
    }
  }
async initializeLevel ( sublevel , options = DEFAULT_GET_OPTIONS ) { if ( sublevel === 'managementLevel' ) { throw new Error ( 'Reserved level' ) ; } try { const tmpOptions = await this . managementLevel . get ( sublevel ) ; let memorySubLevel = null ; if ( this . readInMemory ) { memorySubLevel = this . memoryLevels . get ( sublevel ) ; } const diskSubLevel = subleveldown ( this . db , sublevel , tmpOptions ) ; return [ diskSubLevel , memorySubLevel ] ; } catch ( error ) { if ( ! options ) { throw new Error ( error . message ) ; } const diskSublevel = subleveldown ( this . db , sublevel , options ) ; await this . managementLevel . put ( sublevel , options ) ; let memorySubLevel = null ; if ( this . readInMemory ) { memorySubLevel = levelup ( encodedown ( memdown ( ) , options ) ) ; this . memoryLevels . set ( sublevel , memorySubLevel ) ; } return [ diskSublevel , memorySubLevel ] ; } }
Initialize or load the disk level and the level copied into memory.
Initialize or load the disk level and the level copied into memory .