本文整理汇总了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