當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript npm-package-lookup.search函數代碼示例

本文整理匯總了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([]);
 }
開發者ID:Vrakfall,項目名稱:.atom,代碼行數:24,代碼來源:babelrc-plugins-proposal-provider.ts

示例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


注:本文中的npm-package-lookup.search函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。