当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.takeWhile函数代码示例

本文整理汇总了TypeScript中lodash.takeWhile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript takeWhile函数的具体用法?TypeScript takeWhile怎么用?TypeScript takeWhile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了takeWhile函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: categorizedTokens

    @memoizeAccessor
    private get categorizedTokens() {
        /**
         * @link http://stackoverflow.com/a/10939280/1149074
         */
        const parameterAssignmentTokens = _.takeWhile(this.tokens, token => token.value.includes("="));

        const commandWordToken = this.tokens[parameterAssignmentTokens.length];

        const beforeArgumentListTokensCount = parameterAssignmentTokens.length + 1;
        const argumentListTokens = _.takeWhile(this.tokens.slice(beforeArgumentListTokensCount), token => !(
            token instanceof Scanner.InputRedirectionSymbol ||
            token instanceof Scanner.OutputRedirectionSymbol ||
            token instanceof Scanner.AppendingOutputRedirectionSymbol
        ));

        const ioRedirectTokens = this.tokens.slice(beforeArgumentListTokensCount + argumentListTokens.length);

        return {
            parameterAssignment: parameterAssignmentTokens,
            commandWord: commandWordToken,
            argumentList: argumentListTokens,
            ioRedirect: ioRedirectTokens,
        };
    }
开发者ID:maecro,项目名称:black-screen,代码行数:25,代码来源:Parser.ts

示例2:

    return _.map(timestampeds, (values, outcome: string) => {
      let result: T | undefined;
      const beforeBucket = _.takeWhile(values, (pl) => pl.timestamp <= bucket.timestamp);
      if (beforeBucket.length > 0) {
        _.drop(values, beforeBucket.length);
        result = _.last(beforeBucket);
      }

      if (!result) result = Object.assign({ outcome }, defaultValue);
      result.timestamp = bucket.timestamp;

      return result;
    });
开发者ID:AugurProject,项目名称:augur_node,代码行数:13,代码来源:get-profit-loss.ts

示例3: getCommonAncestor

  // given two paths, returns
  // 1. the common ancestor of the paths
  // 2. the array of ancestors between common ancestor and path1
  // 3. the array of ancestors between common ancestor and path2
  public async getCommonAncestor(path1: Path, path2: Path): Promise<[Path, Array<Path>, Array<Path>]> {
    const ancestors1: Array<Path> = path1.getAncestryPaths();
    const ancestors2: Array<Path> = path2.getAncestryPaths();

    const commonAncestry = _.takeWhile(
      _.zip(ancestors1, ancestors2),
      (pair: any) => (pair[0] && pair[1] && pair[0].is(pair[1]))
    ).map((pair) => pair[0]);

    const lastCommon = _.last(commonAncestry);
    if (lastCommon == null) {
        throw new Error(`No common ancestor found between ${path1} and ${path2}`);
    }
    const firstDifference = commonAncestry.length;
    return [lastCommon, ancestors1.slice(firstDifference), ancestors2.slice(firstDifference)];
  }
开发者ID:gsastry,项目名称:vimflowy,代码行数:20,代码来源:document.ts


注:本文中的lodash.takeWhile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。