Skip to content

Commit

Permalink
Mark parameter to MiniSearch.removeAll as optional
Browse files Browse the repository at this point in the history
According to the documentation, `documents` is optional. However, with
current typing it was not possible to call it without an argument.
  • Loading branch information
nilclass committed Oct 22, 2020
1 parent dc1f04b commit b749c4d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MiniSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,17 @@ export default class MiniSearch<T = any> {
* more efficient to call this method with no arguments than to pass all
* documents.
*/
removeAll (documents: T[]): void {
if (arguments.length === 0) {
removeAll (documents?: T[]): void {
if (documents) {
documents.forEach(document => this.remove(document))
} else {
this._index = new SearchableMap()
this._documentCount = 0
this._documentIds = {}
this._fieldLength = {}
this._averageFieldLength = {}
this._storedFields = {}
this._nextId = 0
} else {
documents.forEach(document => this.remove(document))
}
}

Expand Down

0 comments on commit b749c4d

Please sign in to comment.