Skip to content

Commit a3892ec

Browse files
committed
docs: clean up methods API anchors
1 parent 0467de5 commit a3892ec

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

docs/api/methods.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Methods
22

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

5-
Set/replace the entire collection of documents. If no index is provided, one will be generated.
6-
7-
**Example**
5+
Set/replace the entire collection of documents. If no index is provided, one will be generated. Example:
86

97
```js
108
const fruits = ['apple', 'orange']
@@ -13,11 +11,9 @@ const fuse = new Fuse(fruits)
1311
fuse.setCollection(['banana', 'pear'])
1412
```
1513

16-
### `add(doc: T): void`
17-
18-
Adds a doc to the collection.
14+
### `add`
1915

20-
**Example**
16+
Adds a doc to the collection. Example:
2117

2218
```js
2319
const fruits = ['apple', 'orange']
@@ -29,11 +25,9 @@ console.log(fruits.length)
2925
// => 3
3026
```
3127

32-
### `remove(predicate: (doc: T, idx: number) => boolean): T[]`
33-
34-
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)`.
28+
### `remove`
3529

36-
**Example**
30+
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:
3731

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

53-
### `removeAt(idx: number): void`
47+
### `removeAt`
5448

55-
Removes the doc at the specified index.
56-
57-
**Example**
49+
Removes the doc at the specified index. Example:
5850

5951
```js
6052
const fruits = ['apple', 'orange', 'banana', 'pear']
@@ -66,6 +58,14 @@ console.log(fruits)
6658
// => ['apple', 'banana', 'pear']
6759
```
6860

69-
### `getIndex(): FuseIndex<T>`
61+
### `getIndex`
62+
63+
Returns the generated Fuse index. Example:
7064

71-
Returns the generated Fuse index.
65+
```js
66+
const fruits = ['apple', 'orange', 'banana', 'pear']
67+
const fuse = new Fuse(fruits)
68+
69+
console.log(fuse.getIndex().size())
70+
// => 4
71+
```

0 commit comments

Comments
 (0)