Skip to content

Commit

Permalink
Make calling MiniSearch.removeAll with invalid documents an error
Browse files Browse the repository at this point in the history
  • Loading branch information
nilclass committed Oct 22, 2020
1 parent b749c4d commit 0bb4205
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/MiniSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ export default class MiniSearch<T = any> {
removeAll (documents?: T[]): void {
if (documents) {
documents.forEach(document => this.remove(document))
} else if (arguments.length > 0) {
throw new Error('Expected documents to be present. Omit the argument to remove all documents.')
} else {
this._index = new SearchableMap()
this._documentCount = 0
Expand Down

0 comments on commit 0bb4205

Please sign in to comment.