Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 added the semver-patch Bug fixes that are backward compatible label Sep 15, 2019
@vweevers vweevers added this to In progress in Level (old board) via automation Sep 15, 2019
@vweevers vweevers moved this from In progress to Review in Level (old board) Sep 15, 2019
@vweevers vweevers merged commit 10ee4d9 into master Sep 17, 2019
Level (old board) automation moved this from Review to Done 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Bug fixes that are backward compatible
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants