本文整理匯總了TypeScript中fuzzaldrin-plus.score函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript score函數的具體用法?TypeScript score怎麽用?TypeScript score使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了score函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: transform
transform(inputString: string, query: string) {
return query.length > 0 ? Fuzzy.score(inputString, query, { usePathScoring: false }) !== 0 : true;
}
示例2:
]
const objectCandidates = candidates.map(s => ({ foo: s }))
const options: fz.IOptions = { allowErrors: true }
const filterOptions: fz.IFilterOptions = {
allowErrors: true,
key: 'foo'
}
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
示例3: score
function score(str: string, query: string, maxScore: number) {
return fuzzAldrin.score(str, query, undefined, options) / maxScore
}
示例4: score
function score(str: string, query: string, maxScore: number) {
return fuzzAldrin.score(str, query) / maxScore
}
示例5:
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);