Skip to content

Commit

Permalink
Document input to parseIndex explicitly
Browse files Browse the repository at this point in the history
This takes a javascript Object, not a String.
  • Loading branch information
dbaynard authored Oct 16, 2024
1 parent b6b92ef commit f18438a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/api/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Fuse will automatically index the table if one isn't provided during instantiati

### `Fuse.parseIndex`

Parses a serialized Fuse index.
Parses a serialized Fuse index from a json object representation.

**Example**

Expand All @@ -69,9 +69,14 @@ fs.writeFile('fuse-index.json', JSON.stringify(myIndex.toJSON()))
// (2) When app starts
// Load and deserialize index
const fuseIndex = await require('fuse-index.json')
// Alternatively, if fetching the index, convert to json before parsing.
const fuseIndex = await fetch('./fuse-index.json').then(r => r.json())

const myIndex = Fuse.parseIndex(fuseIndex)
// initialize Fuse with the index
const fuse = new Fuse(books, options, myIndex)


```

<Donate />

0 comments on commit f18438a

Please sign in to comment.