Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Use reachdown #75

Merged
merged 4 commits into from
Sep 17, 2019
Merged

Use reachdown #75

merged 4 commits into from
Sep 17, 2019

Conversation

vweevers
Copy link
Member

Use reachdown instead of:

subleveldown/leveldown.js

Lines 183 to 189 in 992353b

function down (db, type) {
if (typeof db.down === 'function') return db.down(type)
if (type && db.type === type) return db
if (isLooseAbstract(db.db)) return down(db.db, type)
if (isLooseAbstract(db._db)) return down(db._db, type)
return type ? null : db
}

Two notable differences:

  • reachdown does not do if (typeof db.down === 'function') return db.down(type). That's OK, we didn't add a down() method anywhere nor did we advertise this ability.
  • subleveldown now doesn't just get the innermost db (db.db.db..). Instead, it traverses down until db is not a levelup, deferred-leveldown or encoding-down instance. This means, if there are additional layers (e.g. encrypt-down, cachedown) subleveldown stops there, not necessarily at the "storage layer".

Canary-tested against cabal-core (which uses the old memdb, I'll be sending them a PR to switch to level-mem).

This PR fails on node 6 because of a new test on encrypt-down which uses ES6. I'll see if I can make that test dependency-free by mocking an abstract-leveldown.

@vweevers vweevers merged commit 10ee4d9 into master Sep 17, 2019
@vweevers vweevers deleted the reachdown branch September 17, 2019 19:14
@vweevers vweevers mentioned this pull request Oct 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semver-patch Bug fixes that are backward compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants