當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.findWhere函數代碼示例

本文整理匯總了TypeScript中underscore.findWhere函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript findWhere函數的具體用法?TypeScript findWhere怎麽用?TypeScript findWhere使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了findWhere函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it('DAY_AFTER_NIGHT - после того как все проснулись и узнали кого убили, необходимо удалить этого игрока из партии, сменить статус', () => {
        let token_1 = 'wef43f',
            players: Array<GamePlayer> = [
                getGamePlayer({role: Roles.INHABITANT}),
                getGamePlayer({role: Roles.INHABITANT, token: token_1}),
                getGamePlayer({role: Roles.MAFIA}),
                getGamePlayer({role: Roles.DOCTOR})
            ],
            round_data = {
                    killed: [token_1]
            };

        status = GameStatus.DAY_AFTER_NIGHT;
        state =  GameStatusReducer(getGameStateAfterNight(round_data, players), GameAction.nextGameStep(status));

        expect(state.time_last_update).not.toBeLessThan(now);
        expect(state.status).toEqual(status);
        expect(state.time_last_update_players).toBeLessThan(now);
        expect(_.findWhere(state.players, {token: token_1})).toBeUndefined();
    });
開發者ID:andreevWork,項目名稱:mafia,代碼行數:20,代碼來源:GameStatusReducerTest.ts

示例2: it

    it('3 ночь приходит голос от мафии', (done) => {
        let unsubscribe;

        mafia_target = _.findWhere(store.getState().players, {role: Roles.INHABITANT}).token;

        unsubscribe = store.subscribe(() => {
            expect(store.getState().status).toBe(GameStatus.VOTE_MAFIA);
            expect(store.getState().active_roles).toEqual([Roles.MAFIA]);
            expect(store.getState().vote_variants).toEqual(_.pluck(store.getState().players.filter(player => player.role !== Roles.MAFIA), 'token'));
            expect(store.getState().votes).toEqual([{who_token: mafia, for_whom_token: mafia_target}]);

            // Отписываемся т. к. store общий для всех тестов
            unsubscribe();
            done();
        });

        store.dispatch(GameAction.vote(
            mafia,
            mafia_target
        ));
    });
開發者ID:andreevWork,項目名稱:mafia,代碼行數:21,代碼來源:FirstScenario.ts

示例3: build

  public async build(executionReport: IExecutionReport): Promise<{ container: Dom; gridOptions: agGridModule.GridOptions }> {
    const { container, agGridElement } = ExecutionReport.standardSectionHeader(this.sectionTitle);
    let gridOptions: agGridModule.GridOptions;
    const topLevelProperty = find(executionReport.children, child => {
      return child.name == this.topLevelProperty && child.children && findWhere(child.children, { name: this.secondLevelProperty });
    });

    if (topLevelProperty && topLevelProperty.children) {
      const secondLevelProperty = findWhere(topLevelProperty.children, { name: this.secondLevelProperty }) as
        | IExecutionReportSimpleSection
        | undefined;

      if (secondLevelProperty) {
        const dataSource = [
          {
            ...new ExecutionReportGenericSection().build(secondLevelProperty),
            ...{ Applied: new GenericValueOutput().output(secondLevelProperty.applied) }
          }
        ];

        const tableBuilder = await new TableBuilder().build(dataSource, agGridElement);
        gridOptions = tableBuilder.gridOptions;
      }
    } else {
      const tableBuilder = await new TableBuilder().build(
        [
          {
            [`${this.sectionTitle}`]: {
              content: `NO DATA AVAILABLE FOR ${this.sectionTitle} IN CURRENT EXECUTION REPORT`
            }
          }
        ],
        agGridElement
      );

      gridOptions = tableBuilder.gridOptions;
    }

    return { container, gridOptions };
  }
開發者ID:coveo,項目名稱:search-ui,代碼行數:40,代碼來源:ExecutionReportSimpleSection.ts

示例4: fillCache

    fillCache(20, numMRRTTokens, false, function(err: any, testValues: any) {
      var responses = testValues.cachedResponses;
      var memCache = testValues.memCache;
      var fakeTokenRequest = testValues.fakeTokenRequest;

      var mrrtEntry: any = _.findWhere(memCache._entries, { isMRRT : true });

      if (!err) {
        compareInputAndCache(responses, memCache, numMRRTTokens);

        var cacheDriver = new CacheDriver(fakeTokenRequest._callContext, cp.authorityTenant, mrrtEntry.resource, mrrtEntry._clientId, memCache, unexpectedRefreshFunction);
        cacheDriver.find({}, function(err: any, entry: any) {
          if (!err) {
            assert(entry, 'Find did not return any entry');
            assertEntriesEqual(mrrtEntry, entry, 'Queried entry did not match expected: ' + JSON.stringify(entry));
          }
          done(err);
          return;
        });
      } else {
        done(err);
        return;
      }
    });
開發者ID:AzureAD,項目名稱:azure-activedirectory-library-for-nodejs,代碼行數:24,代碼來源:cache-driver.ts

示例5: Number

 vm.lockedperks[type] = _.omit(perkMap, (_perk, perkHash) => {
   return _.findWhere(vendorPerks[vm.active][type], { hash: Number(perkHash) });
 });
開發者ID:bhollis,項目名稱:DIM,代碼行數:3,代碼來源:loadout-builder.component.ts

示例6: alreadyExists

 function alreadyExists(set: D1Item[], id: string) {
   return _.findWhere(set, { id }) || _.findWhere(set, { index: id });
 }
開發者ID:bhollis,項目名稱:DIM,代碼行數:3,代碼來源:loadout-builder.component.ts

示例7: getGameStatus

function getGameStatus(rs: RootState, game: Game, caveId?: string): GameStatus {
  const { commons, tasks, downloads } = rs;
  const { profile } = rs.profile;

  let downloadKeys = getByIds(
    commons.downloadKeys,
    commons.downloadKeyIdsByGameId[game.id]
  );

  let cave: CaveSummary;
  let numCaves = 0;
  if (!cave) {
    if (caveId) {
      cave = commons.caves[caveId];
    } else {
      let caves = getByIds(commons.caves, commons.caveIdsByGameId[game.id]);
      numCaves = size(caves);
      cave = first(caves);
    }
  }
  const downloadKey = first(downloadKeys);

  const pressUser = profile.user.pressUser;
  const task = first(tasks.tasksByGameId[game.id]);

  const pendingDownloads = getPendingForGame(downloads, game.id);
  let download: Download;
  if (caveId) {
    download = findWhere(pendingDownloads, { caveId });
  } else {
    download = first(pendingDownloads);
  }

  let isActiveDownload = false;
  let areDownloadsPaused = false;
  let downloadProgress: DownloadProgress;
  if (download) {
    const activeDownload = getActiveDownload(downloads);
    isActiveDownload = download.id === activeDownload.id;
    areDownloadsPaused = downloads.paused;
    downloadProgress = downloads.progresses[download.id];
  }

  let update: GameUpdate;
  if (cave) {
    update = rs.gameUpdates.updates[cave.id];
  }

  const profileId = profile.id;

  return realGetGameStatus(
    game,
    cave,
    numCaves,
    downloadKey,
    pressUser,
    task,
    download,
    downloadProgress,
    update,
    isActiveDownload,
    areDownloadsPaused,
    profileId
  );
}
開發者ID:itchio,項目名稱:itch,代碼行數:65,代碼來源:get-game-status.ts

示例8: getKonteynerById

 getKonteynerById(id: number): IKonteyner {
     return _.findWhere(this.bkgModel.konteynerlar, { id: id });
 }
開發者ID:jmptrader,項目名稱:RotaTsFramework,代碼行數:3,代碼來源:bkg.service.ts

示例9: type

 data.relationships[relationshipName].data.forEach((item: any) => {
     let relationship: any = _.findWhere(included, {id: item.id});
     relationshipList.push(new type(relationship));
 });
開發者ID:acramatte,項目名稱:angular2-jsonapi,代碼行數:4,代碼來源:json-api.model.ts

示例10:

			_.each(results, (trigger) => {
				let o = _.findWhere(timeline, { id: trigger.id })
				if (o) {
					o.trigger.value = trigger.time
				}
			})
開發者ID:baltedewit,項目名稱:tv-automation-state-timeline-resolver,代碼行數:6,代碼來源:conductor.spec.ts


注:本文中的underscore.findWhere函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。