1- import type { AbstractBatch , AbstractIteratorOptions } from 'abstract-leveldown' ;
1+ import type {
2+ AbstractBatch ,
3+ AbstractIteratorOptions ,
4+ } from 'abstract-leveldown' ;
25import type { LevelDB } from 'level' ;
36import type { ResourceAcquire } from '@matrixai/resources' ;
47import type {
@@ -209,14 +212,8 @@ class DB {
209212 * Get from root level
210213 * @internal
211214 */
212- public async _get < T > (
213- keyPath : KeyPath ,
214- raw ?: false ,
215- ) : Promise < T | undefined > ;
216- public async _get (
217- keyPath : KeyPath ,
218- raw : true ,
219- ) : Promise < Buffer | undefined > ;
215+ public async _get < T > ( keyPath : KeyPath , raw ?: false ) : Promise < T | undefined > ;
216+ public async _get ( keyPath : KeyPath , raw : true ) : Promise < Buffer | undefined > ;
220217 public async _get < T > (
221218 keyPath : KeyPath ,
222219 raw : boolean = false ,
@@ -268,16 +265,8 @@ class DB {
268265 * Put from root level
269266 * @internal
270267 */
271- public async _put (
272- keyPath : KeyPath ,
273- value : any ,
274- raw ?: false ,
275- ) : Promise < void > ;
276- public async _put (
277- keyPath : KeyPath ,
278- value : Buffer ,
279- raw : true ,
280- ) : Promise < void > ;
268+ public async _put ( keyPath : KeyPath , value : any , raw ?: false ) : Promise < void > ;
269+ public async _put ( keyPath : KeyPath , value : Buffer , raw : true ) : Promise < void > ;
281270 public async _put (
282271 keyPath : KeyPath ,
283272 value : any ,
@@ -443,13 +432,15 @@ class DB {
443432 if ( options . gt != null ) {
444433 options . gt = Buffer . concat ( [
445434 levelKeyStart ,
446- ( typeof options . gt === 'string' ) ? Buffer . from ( options . gt ) : options . gt
435+ typeof options . gt === 'string' ? Buffer . from ( options . gt ) : options . gt ,
447436 ] ) ;
448437 }
449438 if ( options . gte != null ) {
450439 options . gte = Buffer . concat ( [
451440 levelKeyStart ,
452- ( typeof options . gte === 'string' ) ? Buffer . from ( options . gte ) : options . gte
441+ typeof options . gte === 'string'
442+ ? Buffer . from ( options . gte )
443+ : options . gte ,
453444 ] ) ;
454445 }
455446 if ( options . gt == null && options . gte == null ) {
@@ -458,13 +449,15 @@ class DB {
458449 if ( options ?. lt != null ) {
459450 options . lt = Buffer . concat ( [
460451 levelKeyStart ,
461- ( typeof options . lt === 'string' ) ? Buffer . from ( options . lt ) : options . lt
452+ typeof options . lt === 'string' ? Buffer . from ( options . lt ) : options . lt ,
462453 ] ) ;
463454 }
464455 if ( options ?. lte != null ) {
465456 options . lte = Buffer . concat ( [
466457 levelKeyStart ,
467- ( typeof options . lte === 'string' ) ? Buffer . from ( options . lte ) : options . lte
458+ typeof options . lte === 'string'
459+ ? Buffer . from ( options . lte )
460+ : options . lte ,
468461 ] ) ;
469462 }
470463 if ( options . lt == null && options . lte == null ) {
@@ -477,11 +470,7 @@ class DB {
477470 const next = iterator . next . bind ( iterator ) ;
478471 // @ts -ignore AbstractIterator type is outdated
479472 iterator . seek = ( k : Buffer | string ) : void => {
480- seek (
481- utils . keyPathToKey (
482- [ ...levelPath , k ] as unknown as KeyPath
483- )
484- ) ;
473+ seek ( utils . keyPathToKey ( [ ...levelPath , k ] as unknown as KeyPath ) ) ;
485474 } ;
486475 // @ts -ignore AbstractIterator type is outdated
487476 iterator . next = async ( ) => {
@@ -492,9 +481,7 @@ class DB {
492481 if ( kv [ 0 ] != null ) {
493482 // Truncate level path so the returned key is relative to the level path
494483 const keyPath = utils . parseKey ( kv [ 0 ] ) . slice ( levelPath . length ) ;
495- kv [ 0 ] = utils . keyPathToKey (
496- keyPath as unknown as KeyPath
497- ) ;
484+ kv [ 0 ] = utils . keyPathToKey ( keyPath as unknown as KeyPath ) ;
498485 }
499486 // Handle values: false
500487 if ( kv [ 1 ] != null ) {
@@ -511,9 +498,7 @@ class DB {
511498 * This is not atomic, it will iterate over a snapshot of the DB
512499 */
513500 @ready ( new errors . ErrorDBNotRunning ( ) )
514- public async clear (
515- levelPath : LevelPath = [ ] ,
516- ) : Promise < void > {
501+ public async clear ( levelPath : LevelPath = [ ] ) : Promise < void > {
517502 levelPath = [ 'data' , ...levelPath ] ;
518503 if ( utils . checkSepLevelPath ( levelPath ) ) {
519504 throw new errors . ErrorDBLevelSep ( ) ;
@@ -525,10 +510,7 @@ class DB {
525510 * Clear from root level
526511 * @internal
527512 */
528- public async _clear (
529- db : LevelDB ,
530- levelPath : LevelPath = [ ] ,
531- ) : Promise < void > {
513+ public async _clear ( db : LevelDB , levelPath : LevelPath = [ ] ) : Promise < void > {
532514 for await ( const [ k ] of this . _iterator ( db , { values : false } , levelPath ) ) {
533515 await db . del ( utils . keyPathToKey ( [ ...levelPath , k ] as unknown as KeyPath ) ) ;
534516 }
@@ -547,10 +529,19 @@ class DB {
547529 * Dump from root level
548530 * It is intended for diagnostics
549531 */
550- public async dump ( levelPath ?: LevelPath , raw ?: false ) : Promise < Array < [ string , any ] > > ;
551- public async dump ( levelPath : LevelPath | undefined , raw : true ) : Promise < Array < [ Buffer , Buffer ] > > ;
532+ public async dump (
533+ levelPath ?: LevelPath ,
534+ raw ?: false ,
535+ ) : Promise < Array < [ string , any ] > > ;
536+ public async dump (
537+ levelPath : LevelPath | undefined ,
538+ raw : true ,
539+ ) : Promise < Array < [ Buffer , Buffer ] > > ;
552540 @ready ( new errors . ErrorDBNotRunning ( ) )
553- public async dump ( levelPath : LevelPath = [ ] , raw : boolean = false ) : Promise < Array < [ string | Buffer , any ] > > {
541+ public async dump (
542+ levelPath : LevelPath = [ ] ,
543+ raw : boolean = false ,
544+ ) : Promise < Array < [ string | Buffer , any ] > > {
554545 if ( utils . checkSepLevelPath ( levelPath ) ) {
555546 throw new errors . ErrorDBLevelSep ( ) ;
556547 }
0 commit comments