本文整理匯總了TypeScript中npm-package-lookup.search函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript search函數的具體用法?TypeScript search怎麽用?TypeScript search使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了search函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getProposals
getProposals(request: IRequest): Promise<Array<IProposal>> {
const {segments, contents, prefix, isBetweenQuotes, shouldAddComma} = request;
if (PRESET_MATCHER.matches(request)) {
const plugins: Array<string> = contents[PLUGINS] || [];
const results: Promise<Array<string>> = search(this.calculateSearchKeyword(prefix));
return results.then(names => {
return names.filter(name => plugins.indexOf(name.replace(BABEL_PLUGIN, '')) < 0).map(pluginName => {
const name = pluginName.replace(BABEL_PLUGIN, '');
const proposal: IProposal = {};
proposal.displayText = name;
proposal.rightLabel = 'plugin';
proposal.type = 'plugin';
proposal.description = `${name} babel plugin. Required dependency in package.json: ${pluginName}`;
if (isBetweenQuotes) {
proposal.text = name;
} else {
proposal.snippet = '"' + name + '"' + (shouldAddComma ? ',' : '');
}
return proposal;
});
});
}
return Promise.resolve([]);
}
示例2: getDependencyKeysProposals
getDependencyKeysProposals(request: IRequest): Promise<Array<IProposal>> {
const {prefix} = request;
return search(prefix).then((packageNames: Array<string>) => this.transformPackageNames(packageNames, request));
}
開發者ID:GabrielNicolasAvellaneda,項目名稱:autocomplete-json,代碼行數:4,代碼來源:package-json-dependency-proposal-provider.ts