當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。