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


TypeScript lodash.trimLeft函數代碼示例

本文整理匯總了TypeScript中lodash.trimLeft函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript trimLeft函數的具體用法?TypeScript trimLeft怎麽用?TypeScript trimLeft使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了trimLeft函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getDependencyVersionsProposals

 getDependencyVersionsProposals(request: IRequest): Promise<Array<IProposal>> {
   const {segments, prefix} = request;
   const [, packageName, ...rest] = segments;
   const trimmedPrefix = trimLeft(prefix, '~^<>="');
   return this.config.versions(packageName.toString()).then(versions =>
     versions.filter(version => startsWith(version, trimmedPrefix))
       .map(version => createVersionProposal(request, version))
   );
 }
開發者ID:Belgabor,項目名稱:autocomplete-json,代碼行數:9,代碼來源:semver-dependency-proposal-provider.ts

示例2: containerName

function containerName(root: string, segments: Array<string>): string {
  // Empty prefix or segments, search in the root folder.
  if (isEmpty(segments)) {
    return root;
  }
  // Last character is some kind of slash.
  if (isEmpty(last(segments))) {
    // this means, the last segment was (or should be) a directory.
    const path = root + sep + trimLeft(segments.join(sep), '/\\');
    if (directoryExists(path)) {
      return path;
    }
  } else {
    // Last segment is not a slash, meaning we don't need, what the user typed until the last slash.
    const lastIsPartialFile = root + sep + trimLeft(segments.slice(0, segments.length - 1).join(sep), '/\\');
    if (directoryExists(lastIsPartialFile)) {
      return lastIsPartialFile;
    }
  }
  // User wants completions for non existing directory.
  return null;
}
開發者ID:Belgabor,項目名稱:autocomplete-json,代碼行數:22,代碼來源:file-proposal-provider.ts

示例3: createVersionProposal

function createVersionProposal(request: IRequest, version: string): IProposal {
  const {isBetweenQuotes, shouldAddComma, prefix} = request;
  const proposal: IProposal = {}
  proposal.displayText = version;
  proposal.rightLabel = 'version';
  proposal.type = 'value';
  proposal.replacementPrefix = trimLeft(prefix, '~^<>="');
  if (isBetweenQuotes) {
    proposal.text = version;
  } else {
    proposal.snippet = '"' + version + '"' + (shouldAddComma ? ',' : '');
  }
  return proposal;
}
開發者ID:Belgabor,項目名稱:autocomplete-json,代碼行數:14,代碼來源:semver-dependency-proposal-provider.ts


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