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


TypeScript lodash.findLastIndex函数代码示例

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


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

示例1: findHitSubPath

 private findHitSubPath(hits: ReadonlyArray<{ subIdx: number }>) {
   const infos = hits.map(index => {
     const { subIdx } = index;
     return { subIdx, subPath: this.component.activePath.getSubPath(subIdx) };
   });
   const lastSplitIndex = _.findLastIndex(infos, info => info.subPath.isSplit());
   return infos[lastSplitIndex < 0 ? infos.length - 1 : lastSplitIndex];
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:8,代码来源:PairSubPathHelper.ts

示例2: playDisc

  playDisc(column: number, color: string): boolean {
    let rowOfCellToChange: number = _.findLastIndex(this.cells[column], (cell: string) => this.cellIsEmpty(cell));
    if (!this.rowIsValid(rowOfCellToChange)) return false;

    let discPlayed: Disc = new Disc(new Location(column, rowOfCellToChange), color);
    this.setCell(discPlayed);
    this.lastDiscPlayed = discPlayed;
    return true;
  }
开发者ID:wesdun,项目名称:ConnectFour,代码行数:9,代码来源:board.ts

示例3: children

    @memoizeAccessor
    get children(): ASTNode[] {
        const separatorOpIndex = _.findLastIndex(this.tokens, isEndOfCommand);

        if (separatorOpIndex !== -1) {
            return [
                new List(this.tokens.slice(0, separatorOpIndex)),
                new ShellSyntaxNode(this.tokens[separatorOpIndex]),
                new AndOr(this.tokens.slice(separatorOpIndex + 1)),
            ];
        } else {
            return [
                new AndOr(this.tokens),
            ];
        }
    }
开发者ID:sunyton,项目名称:upterm,代码行数:16,代码来源:Parser.ts

示例4: children

    @memoizeAccessor
    get children(): ASTNode[] {
        const separatorOpIndex = _.findLastIndex(this.tokens, token => token instanceof Scanner.Semicolon);

        if (separatorOpIndex !== -1) {
            return [
                new List(this.tokens.slice(0, separatorOpIndex)),
                new ShellSyntaxNode(this.tokens[separatorOpIndex]),
                new AndOr(this.tokens.slice(separatorOpIndex + 1)),
            ];
        } else {
            return [
                new AndOr(this.tokens),
            ];
        }
    }
开发者ID:maecro,项目名称:black-screen,代码行数:16,代码来源:Parser.ts

示例5: _addToPosition

function _addToPosition(
    obj: MenuItemOptions,
    target: MenuItemOptions[],
    position: string,
    relativeId: string | null
): string | null {
    let retVal: string | null = null;
    if (position === "first") {
        target.unshift(obj);
    } else if (position === "last") {
        target.push(obj);
    } else if (
        position === "before" || position === "after" || position === "firstInSection" || position === "lastInSection"
    ) {
        let idx = _.findIndex(target, {id: relativeId});
        let idxSection: number;
        if (idx === -1) {
            // NOTE: original behaviour - if relativeId wasn't found
            // menu should be put to the end of the list
            console.warn("menu item with id: " + relativeId + " was not found, adding entry to the end of the list");
            retVal = ERR_NOT_FOUND;
            idx = target.length;
        }
        if (position === "firstInSection") {
            idxSection = _.findLastIndex(target, (o: MenuItemOptions, i: number) => {
                return i < idx && o.type === "separator";
            });
            idx = idxSection + 1;
        }
        if (position === "lastInSection") {
            idxSection = _.findIndex(target, (o: MenuItemOptions, i: number) => {
                return i >= idx && o.type === "separator";
            });
            idx = idxSection === -1 ? target.length : idxSection;
        }
        if (position === "after") {
            idx++;
        }
        target.splice(idx, 0, obj);
    } else {
        throw new Error("position not implemented in _addToPosition: " + position);
    }
    return retVal;
}
开发者ID:Real-Currents,项目名称:brackets,代码行数:44,代码来源:app-menu.ts

示例6: calculateDeletedSubIdxs

 /**
  * Calculates the sub path indices that will be removed after unsplitting subIdx.
  * targetCs is the command state object containing the split segment in question.
  */
 private calculateDeletedSubIdxs(subIdx: number, targetCs: CommandState) {
   const splitSegId = targetCs.getSplitSegmentId();
   const psps = this.findSplitSegmentParentNode(splitSegId);
   const pssps = psps.getSplitSubPaths();
   const splitSubPathIdx1 = _.findIndex(pssps, sps => {
     return sps.getCommandStates().some(cs => cs.getSplitSegmentId() === splitSegId);
   });
   const splitSubPathIdx2 = _.findLastIndex(pssps, sps => {
     return sps.getCommandStates().some(cs => cs.getSplitSegmentId() === splitSegId);
   });
   const pssp1 = pssps[splitSubPathIdx1];
   const pssp2 = pssps[splitSubPathIdx2];
   const deletedSps = [...flattenSubPathStates([pssp1]), ...flattenSubPathStates([pssp2])];
   const spss = flattenSubPathStates(this.subPathStateMap);
   return deletedSps
     .slice(1)
     .map(sps => this.subPathOrdering[spss.indexOf(sps)])
     .sort((a, b) => b - a);
 }
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:23,代码来源:Path.ts

示例7: findLastIndex

      .success(function(ret) {
        $scope.revisions = ret.revisions;
        $scope.latestOAIdx = findLastIndex(ret.revisions, {isOpenAccess: true});

        const latestOARevision = $scope.revisions[$scope.latestOAIdx];
        // Cut description down to 150 chars, cf.
        // <http://moz.com/learn/seo/meta-description>
        // TODO move linebreak removal to backend?
        const metaData = [
          {
            name: 'description',
            content: latestOARevision.title + ' by ' + latestOARevision.authors.join(', ') + '.'
          },
          {name: 'author', content: latestOARevision.authors.join(', ')},
          {name: 'keywords', content: latestOARevision.tags.join(', ')}
        ];

        $scope.addDocumentMetaData(metaData);

        metaService.set({
          title: latestOARevision.title + ' ¡ PaperHive',
          meta: metaData
        });
      })
开发者ID:carolinagc,项目名称:paperhive-frontend,代码行数:24,代码来源:document.ts

示例8: get

  get(index) {

    if (index === undefined) {
      index = this.index;
    }

    if (this.validateIndex(index)) {

      if (index !== -1 && this.eventType) {
        let _index = _.findLastIndex(this.events.slice(0, index + 1), { type: this.eventType });
        if (_index === -1) {
          return null;
        } else {
          index = _index;
        }
      }

      let events = this.events.slice(0, index + 1);
      this.index = index;
      return reborn(this.ActorClass, this.lastSnap, events).json;
    } else {
      return null;
    }
  }
开发者ID:liangzeng,项目名称:cqrs,代码行数:24,代码来源:History.ts


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