@@ -5,7 +5,16 @@ var deferrables = 'put get del batch clear'.split(' ')
5
5
var optionalDeferrables = 'approximateSize compactRange' . split ( ' ' )
6
6
7
7
function DeferredLevelDOWN ( db ) {
8
- AbstractLevelDOWN . call ( this , '' )
8
+ AbstractLevelDOWN . call ( this , db . supports || { } )
9
+
10
+ // TODO (future major): remove this fallback; db must have manifest that
11
+ // declares approximateSize and compactRange in additionalMethods.
12
+ optionalDeferrables . forEach ( function ( m ) {
13
+ if ( typeof db [ m ] === 'function' && ! this . supports . additionalMethods [ m ] ) {
14
+ this . supports . additionalMethods [ m ] = true
15
+ }
16
+ } , this )
17
+
9
18
this . _db = db
10
19
this . _operations = [ ]
11
20
closed ( this )
@@ -51,11 +60,9 @@ function open (self) {
51
60
return this . _db [ m ] . apply ( this . _db , arguments )
52
61
}
53
62
} )
54
- optionalDeferrables . forEach ( function ( m ) {
55
- if ( typeof self . _db [ m ] === 'function' ) {
56
- self [ m ] = function ( ) {
57
- return this . _db [ m ] . apply ( this . _db , arguments )
58
- }
63
+ Object . keys ( self . supports . additionalMethods ) . forEach ( function ( m ) {
64
+ self [ m ] = function ( ) {
65
+ return this . _db [ m ] . apply ( this . _db , arguments )
59
66
}
60
67
} )
61
68
}
@@ -66,11 +73,9 @@ function closed (self) {
66
73
this . _operations . push ( { method : m , args : arguments } )
67
74
}
68
75
} )
69
- optionalDeferrables . forEach ( function ( m ) {
70
- if ( typeof self . _db [ m ] === 'function' ) {
71
- self [ m ] = function ( ) {
72
- this . _operations . push ( { method : m , args : arguments } )
73
- }
76
+ Object . keys ( self . supports . additionalMethods ) . forEach ( function ( m ) {
77
+ self [ m ] = function ( ) {
78
+ this . _operations . push ( { method : m , args : arguments } )
74
79
}
75
80
} )
76
81
self . _iterator = function ( options ) {
0 commit comments