Level / abstract-leveldown

An abstract prototype matching the leveldown API.
MIT License
146 stars 53 forks source link

Singular way to signal iteration end #243

Closed vweevers closed 6 years ago

vweevers commented 6 years ago

From https://github.com/Level/concat-iterator/issues/1#issuecomment-399747452:

So atm, there's two ways in the ecosystem to detect the end of iteration:

  1. arguments.length === 0
  2. key === undefined && value === undefined

We gotta pick one and stick with it.

And

this should be specified in abstract-leveldown and the tests should enforce this.

vweevers commented 6 years ago

I prefer the key-value check, it covers more ground. Because if no arguments are passed, then key === undefined && value === undefined is also true.

@ralphtheninja WDYT?

vweevers commented 6 years ago

This might be a good time to officially drop undefined (perhaps also null) as keys and values (#120).

vweevers commented 6 years ago

I prefer the key-value check, it covers more ground.

In fact that's already how we test it in abstract-leveldown:

https://github.com/Level/abstract-leveldown/blob/a36c04fe5c21e568291f49e2235a9b4cdfde2292/abstract/iterator-test.js#L137-L138

vweevers commented 6 years ago

In other words, no change is required in abstract-leveldown, but since we aren't supporting undefined anyway, we should make that official.

vweevers commented 6 years ago

@ralphtheninja reopen if you disagree.