当前位置: 首页>>代码示例>>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;未经允许,请勿转载。