-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: reject if closed state is incorrect #42
Conversation
Some methods, like `addCore()`, now throw if called after calling `close()`. `unlink()` is the opposite, and should only be called after the indexer is closed. This is arguably a breaking change, but I feel that changing undefined behavior is not breaking.
@@ -139,14 +139,25 @@ Type: `Hypercore` | |||
Add a hypercore to the indexer. Must have the same value encoding as other | |||
hypercores already in the indexer. | |||
|
|||
Rejects if called after the indexer is closed. | |||
|
|||
### indexer.idle() |
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 method was previously undocumented. Because it has a behavior change, I documented it here.
@@ -12,3 +12,13 @@ function pDefer() { | |||
return deferred | |||
} | |||
exports.pDefer = pDefer | |||
|
|||
class ExhaustivenessError extends Error { |
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.
Copy-pasted from mapeo-core-next.
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.
non-blocking comments but lgtm
index.js
Outdated
* Stop the indexer and flush index state to storage. This will not close the | ||
* underlying storage - it is up to the consumer to do that. | ||
* | ||
* Rejects if called more than once. |
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.
is this preferred over no-oping when closed already?
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.
should update the docs with this note to describe the behavior anyways
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.
Some methods, like
addCore()
, now throw if called after callingclose()
.unlink()
is the opposite, and should only be called after the indexer is closed.This is arguably a breaking change, but I feel that changing undefined behavior is not breaking.
Closes #21.