Skip to content

Commit

Permalink
Add manifest (Level/community#83) (#79)
Browse files Browse the repository at this point in the history
* Upgrade abstract-leveldown from ~6.1.0 to ~6.2.1
* Add manifest
  • Loading branch information
vweevers committed Oct 4, 2019
1 parent c64392a commit bad6fd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions deferred-leveldown.js
Expand Up @@ -5,7 +5,16 @@ var deferrables = 'put get del batch clear'.split(' ')
var optionalDeferrables = 'approximateSize compactRange'.split(' ')

function DeferredLevelDOWN (db) {
AbstractLevelDOWN.call(this, '')
AbstractLevelDOWN.call(this, db.supports || {})

// TODO (future major): remove this fallback; db must have manifest that
// declares approximateSize and compactRange in additionalMethods.
optionalDeferrables.forEach(function (m) {
if (typeof db[m] === 'function' && !this.supports.additionalMethods[m]) {
this.supports.additionalMethods[m] = true
}
}, this)

this._db = db
this._operations = []
closed(this)
Expand Down Expand Up @@ -51,11 +60,9 @@ function open (self) {
return this._db[m].apply(this._db, arguments)
}
})
optionalDeferrables.forEach(function (m) {
if (typeof self._db[m] === 'function') {
self[m] = function () {
return this._db[m].apply(this._db, arguments)
}
Object.keys(self.supports.additionalMethods).forEach(function (m) {
self[m] = function () {
return this._db[m].apply(this._db, arguments)
}
})
}
Expand All @@ -66,11 +73,9 @@ function closed (self) {
this._operations.push({ method: m, args: arguments })
}
})
optionalDeferrables.forEach(function (m) {
if (typeof self._db[m] === 'function') {
self[m] = function () {
this._operations.push({ method: m, args: arguments })
}
Object.keys(self.supports.additionalMethods).forEach(function (m) {
self[m] = function () {
this._operations.push({ method: m, args: arguments })
}
})
self._iterator = function (options) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -12,7 +12,7 @@
"prepublishOnly": "npm run dependency-check"
},
"dependencies": {
"abstract-leveldown": "~6.1.0",
"abstract-leveldown": "~6.2.1",
"inherits": "^2.0.3"
},
"devDependencies": {
Expand Down

0 comments on commit bad6fd8

Please sign in to comment.