Skip to content

Commit

Permalink
docs: document input to parseIndex explicitly
Browse files Browse the repository at this point in the history
This takes a javascript `Object`, not a `String`. The difference is
relevant when loading a pre-computed index using a web request, for
example, or when deserializing from OPFS (not shown).
  • Loading branch information
dbaynard committed Oct 17, 2024
1 parent 60eebc5 commit 9e9a7e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 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,6 +69,9 @@ 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)
Expand Down

0 comments on commit 9e9a7e1

Please sign in to comment.