.map((item): IMatch<T> => { const key: string = typeof getKey === 'function' ? (getKey as KeyFunction<T>)(item) : String(item[getKey]) return { score: score(key, query, maxScore), item, matches: fuzzAldrin.match(key, query, undefined, options), } })
fz.filter(candidates, 'install') fz.filter(candidates, 'install', options) fz.filter(candidates, 'install', filterOptions) fz.filter(objectCandidates, 'install', { key: 'foo' }) const preparedQuery: fz.Query = fz.prepareQuery('install') fz.score('Maybe', 'me') fz.score('Maybe', 'me', undefined) fz.score('Maybe', 'me', null) fz.score('Maybe', 'me', {}) fz.score('Maybe', 'me', { allowErrors: true }) fz.score('Application: Install Update', 'install') fz.score('Application: Install Update', 'install', { preparedQuery }) fz.match('Maybe', 'me') fz.match('Application: Install Update', 'install') fz.match('Application: Install Update', 'install', { preparedQuery }) fz.wrap('Maybe', 'me') // // Complex filter cases, using all the options // ---------------------------------------------------------------------- fz.filter(['Maybe', 'Me'], 'me') fz.filter(['Maybe', 'Me'], 'me', undefined) fz.filter(['Maybe', 'Me'], 'me', null) fz.filter(['Maybe', 'Me'], 'me', {}) fz.filter(['Maybe', 'Me'], 'me', { allowErrors: true }) fz.filter(['Maybe', 'Me'], 'me', { key: 'key' })
itemTextArray.forEach(text => { matches.push(fuzzAldrin.match(text, query)) })
import * as fz from "fuzzaldrin-plus"; const candidates = [ 'Find And Replace: Select All', 'Settings View: Uninstall Packages', 'Settings View: View Installed Themes', 'Application: Install Update', 'Install' ] const objectCandidates = candidates.map(s => ({ foo: s })); fz.filter(candidates, 'install'); fz.filter(objectCandidates, 'install', { key: 'foo' }); const prepQuery = fz.prepQuery('install'); fz.score('Application: Install Update', 'install'); fz.score('Application: Install Update', 'install', prepQuery); fz.match('Application: Install Update', 'install'); fz.match('Application: Install Update', 'install', prepQuery);