-
-
Notifications
You must be signed in to change notification settings - Fork 176
Carefully consider behavior of nullish range options #515
Comments
That was fear talking! First, find out how and where |
Yes. Run: var wrap = require('level-option-wrap')
// no gt property
var input = {}
var output = wrap(input, {
gt(x) { return x }
})
if ('gt' in output) {
console.log('we have a problem')
} Still, I struggle to find a case where this is actually a problem. For example,
|
To recap: historically, nullish range options have meant "not defined" in most of the ecosystem, but because it's most and not all, it required a large number of hacks, many undocumented and without integration tests, making it hard to predict behavior, let alone how a change to that behavior will ripple through the ecosystem. In Yes, there is risk of ecosystem breakage, but we have to start somewhere, with a documented, simplest possible behavior, which we did for |
Though the logic in f267647 felt "right", I'm afraid it could break the ecosystem. It could be incompatible with popular tools like
ltgt
. For example,ltgt.lowerBound({})
returnsundefined
.If you're wondering why this doesn't cause problems for
encoding-down
, it has special logic for nullish. It doesn't touch them in the serialization step or in the encoding step (of builtin encodings). This avoids{ gt: undefined }
turning into{ gt: 'undefined' }
.I'm leaning towards reverting f267647, perhaps even the
abstract-leveldown
behavior (so that nullish means "not defined" again everywhere), but this needs some tests and thinking. If possible, I want to avoid needing special logic for nullish in everyabstract-leveldown
implementation. Because really, the only odd duck isencoding-down
.Perhaps, if we revert the
abstract-leveldown
behavior, a new abstract_isValidTarget()
method (bikeshed name) could allowencoding-down
to enable nullish range options:The text was updated successfully, but these errors were encountered: