-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Upgrade to latest Level modules #15
Conversation
abstract.AbstractLevelDOWN.call(this, path) | ||
function Multilevel (opts) { | ||
if (!(this instanceof Multilevel)) return new Multilevel(opts) | ||
abstract.AbstractLevelDOWN.call(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract-leveldown
no longer needs a location (aka path
here).
@@ -38,6 +40,8 @@ function Multilevel (path, opts) { | |||
|
|||
util.inherits(Multilevel, abstract.AbstractLevelDOWN) | |||
|
|||
Multilevel.prototype.type = 'multileveldown' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for compatibility with reachdown
, which I also intend to start using in subleveldown
, level-test
and more.
} | ||
} | ||
|
||
Multilevel.prototype.forward = function (down) { | ||
this._db = down | ||
this._db = reachdown(down, matchdown, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This peels off levelup
, deferred-leveldown
and encoding-down
.
|
||
Multilevel.prototype._serializeValue = function (value) { | ||
return Buffer.isBuffer(value) ? value : Buffer.from(String(value)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures we're only working with buffers internally.
Multilevel.prototype._get = function (key, opts, cb) { | ||
if (this._db) return this._db._get(key, opts, cb) | ||
|
||
var req = { | ||
tag: 0, | ||
id: 0, | ||
key: key, | ||
valueEncoding: opts.valueEncoding || (opts.asBuffer === false ? 'utf-8' : 'binary'), | ||
valueAsBuffer: opts.asBuffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer have access to key/ValueEncoding
options here, but we don't need it. We only have to care about returning a buffer or string (which at a higher level, is dictated by encoding-down
and the user's choice of encoding).
@@ -29,7 +32,7 @@ module.exports = function (db, opts) { | |||
return stream | |||
|
|||
function ready () { | |||
var down = db.db | |||
var down = reachdown(db, matchdown, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This peels off levelup
, deferred-leveldown
and encoding-down
.
} | ||
|
||
this._iterator = down.iterator(req.options) | ||
this._iterator = down.iterator(cleanRangeOptions(req.options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because null
and undefined
are valid range options in latest abstract-leveldown
, we must strip them from the options object.
@vweevers Any chance of seeing this and Do you think we should do a proper fork? |
We can move these modules to Level if @mafintosh is cool with that. |
Would be really nice, I'm currently stuck on Node 8 because I'm using |
I’m very cool with that! |
Thanks @mafintosh! Do we need @substack for moving |
Semver-major. Goes hand-in-hand with a
level-party
PR which I'll open shortly. Achieves the following:memdown
, which now internally stores keys+values as Buffers, making it more reliable as aleveldown
replacementdb
that isn'tlevel
(may or may not havelevelup
,encoding-down
,deferred-leveldown
layers, and may have additional layers)level-party
needs on themultileveldown
client, so thatlevel-party
doesn't have to reach down (e.g.db.db
)subleveldown
onlevel-party
subleveldown
onmultileveldown
client (i.e. for client-side sublevels)multileveldown
server onsubleveldown
(i.e. to expose only a sublevel to client)