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