diff --git a/docs/api/indexing.md b/docs/api/indexing.md index 7c04ebbc2..5fd56cacb 100644 --- a/docs/api/indexing.md +++ b/docs/api/indexing.md @@ -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** @@ -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) diff --git a/src/index.d.ts b/src/index.d.ts index a039a8307..d6f3c9d21 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -91,7 +91,10 @@ declare class Fuse { ): FuseIndex public static parseIndex( - index: any, + index: { + keys: ReadonlyArray + records: FuseIndexRecords + }, options?: FuseIndexOptions ): FuseIndex