Skip to content

Commit

Permalink
docs: clean up methods API anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
krisk committed Jun 22, 2020
1 parent 0467de5 commit a3892ec
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/api/methods.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Methods

### `setCollection(docs: T[], index?: FuseIndex<T>): void`
### `setCollection`

Set/replace the entire collection of documents. If no index is provided, one will be generated.

**Example**
Set/replace the entire collection of documents. If no index is provided, one will be generated. Example:

```js
const fruits = ['apple', 'orange']
Expand All @@ -13,11 +11,9 @@ const fuse = new Fuse(fruits)
fuse.setCollection(['banana', 'pear'])
```

### `add(doc: T): void`

Adds a doc to the collection.
### `add`

**Example**
Adds a doc to the collection. Example:

```js
const fruits = ['apple', 'orange']
Expand All @@ -29,11 +25,9 @@ console.log(fruits.length)
// => 3
```

### `remove(predicate: (doc: T, idx: number) => boolean): T[]`

Removes all documents from the list which the predicate returns truthy for, and returns an array of the removed docs. The predicate is invoked with two arguments: `(doc, index)`.
### `remove`

**Example**
Removes all documents from the list which the predicate returns truthy for, and returns an array of the removed docs. The predicate is invoked with two arguments: `(doc, index)`. Example:

```js
const fruits = ['apple', 'orange', 'banana', 'pear']
Expand All @@ -50,11 +44,9 @@ console.log(results)
// => ['banana', 'pear']
```

### `removeAt(idx: number): void`
### `removeAt`

Removes the doc at the specified index.

**Example**
Removes the doc at the specified index. Example:

```js
const fruits = ['apple', 'orange', 'banana', 'pear']
Expand All @@ -66,6 +58,14 @@ console.log(fruits)
// => ['apple', 'banana', 'pear']
```

### `getIndex(): FuseIndex<T>`
### `getIndex`

Returns the generated Fuse index. Example:

Returns the generated Fuse index.
```js
const fruits = ['apple', 'orange', 'banana', 'pear']
const fuse = new Fuse(fruits)

console.log(fuse.getIndex().size())
// => 4
```

0 comments on commit a3892ec

Please sign in to comment.