farzher / fuzzysort

Fast SublimeText-like fuzzy search for JavaScript.

Home Page:https://rawgit.com/farzher/fuzzysort/master/test/test.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

initialize the search the entire JSON?

halukkaramete opened this issue · comments

First of all, this is an outstanding work & thank you for sharing it.

Your demo here (https://rawgit.com/farzher/fuzzysort/master/test.html) starts with searching only the "ue4_filanames" json section.
That's because of this line:
var testdatakey = 'ue4_filenames'

Is it possible to start the search across the board with something like this?
var testdatakey = testdata;

you'd have to run fuzzysort multiple times and merge the results

// accepts an array of targets and merges the results
function gomultipletargets(search, multipletargets, options) {
  return multipletargets
    .flatMap(targets => fuzzysort.go(search, targets, options))
    .sort((a,b) => b.score - a.score)
}

// in your case
const multipletargets = Object.keys(testdata_prepared).map(key => testdata_prepared[key])
gomultipletargets('test', multipletargets)