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


TypeScript underscore.where函數代碼示例

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


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

示例1:

    const mapData = _.map(labels, (label) => {
      if (vm.item.destinyVersion === 1) {
        const matchingReviews = _.where(itemReviews, { rating: label });
        const highlightedReviews = _.where(matchingReviews, { isHighlighted: true });

        return matchingReviews.length + highlightedReviews.length * 4;
      } else {
        const highlightedReviews = itemReviews.filter((review) => review.isHighlighted);
        return itemReviews.length + highlightedReviews.length * 4;
      }
    });
開發者ID:bhollis,項目名稱:DIM,代碼行數:11,代碼來源:item-review.component.ts

示例2: getPerkNodesInColumn

function getPerkNodesInColumn(item: D1Item, column): D1GridNode[] {
  if (!item.talentGrid) {
    return [];
  }

  return _.where(item.talentGrid.nodes, { column });
}
開發者ID:bhollis,項目名稱:DIM,代碼行數:7,代碼來源:perkRater.ts

示例3: function

		selection: function(){
			//returning the new array systematically breaks the watcher
			//due to the reference always being updated
			var currentSelection = _.where(this.all, { selected: true }) || [];
			if(!this._selection || this._selection.length !== currentSelection.length){
				this._selection = currentSelection;
			}
			return this._selection;
		},
開發者ID:entcore,項目名稱:infra-front,代碼行數:9,代碼來源:lib.ts

示例4:

 this.loadCredentials().then((entries) => {
     // Find the entry I want based on service
     let entryArray: Array<any> = _.where(entries, { service: service });
     if (entryArray !== undefined && entryArray.length > 0) {
         let credential: Credential = this.createCredential(entryArray[0]);
         deferred.resolve(credential);
     } else {
         deferred.resolve(undefined);
     }
 })
開發者ID:chrisdias,項目名稱:vsts-vscode,代碼行數:10,代碼來源:linux-file-api.ts

示例5:

 .then((body2)=> { 
    var resultJson = JSON.parse(body2);
    var gameCount = +resultJson.response.game_count;
    var gameNotPlayed = +_.where(resultJson.response.games, {playtime_forever: 0}).length;
    var total = (gameNotPlayed/gameCount) *100;
    
    if(total > 60){
     return "You have more than enough games to play for now." 
    } else {
     return "Go ahead if you have the money."
    }
              
 })
開發者ID:DouglasPonce85,項目名稱:acklen-slackbot,代碼行數:13,代碼來源:GamerBotHelper.ts

示例6: it

    it('2 ночь путана проголосует и это уже не имеет значения', (done) => {
        let unsubscribe;

        real_man = _.last(_.without(_.pluck(_.where(store.getState().players, {role: Roles.INHABITANT}), 'token'), mafia_target));

        unsubscribe = store.subscribe(() => {
            expect(store.getState().status).toBe(GameStatus.VOTE_WHORE);
            expect(store.getState().active_roles).toEqual([Roles.WHORE]);
            expect(store.getState().vote_variants).toEqual(_.pluck(store.getState().players.filter(player => player.token !== whore), 'token'));
            expect(store.getState().votes).toEqual([{who_token: whore, for_whom_token: real_man}]);

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

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

示例7: destroyWhere

 /**
  * Destroy all records matching criteria.
  * @see where
  * @param criteria
  * @returns {boolean}
  */
 destroyWhere(criteria) {
     var matches = _.where(this._rows, criteria);
     var newRows = _.difference(this._rows, matches);
     this._rows = newRows;
     return this.save();
 }
開發者ID:lorddoig,項目名稱:lsdb,代碼行數:12,代碼來源:lsdb.ts

示例8: quickApplyBlocks

  async quickApplyBlocks(blocks:BlockDTO[], to: number): Promise<void> {

    sync_memoryDAL.sindexDAL = { getAvailableForConditions: (conditions:string) => this.dal.sindexDAL.getAvailableForConditions(conditions) }
    let blocksToSave: BlockDTO[] = [];

    for (const block of blocks) {
      sync_allBlocks.push(block);

      // The new kind of object stored
      const dto = BlockDTO.fromJSONObject(block)

      if (block.number == 0) {
        sync_currConf = BlockDTO.getConf(block);
      }

      if (block.number <= to - this.conf.forksize) {
        blocksToSave.push(dto);
        const index:any = Indexer.localIndex(dto, sync_currConf);
        const local_iindex = Indexer.iindex(index);
        const local_cindex = Indexer.cindex(index);
        const local_sindex = Indexer.sindex(index);
        const local_mindex = Indexer.mindex(index);

        const HEAD = await Indexer.quickCompleteGlobalScope(block, sync_currConf, sync_bindex, local_iindex, local_mindex, local_cindex, {
          getBlock: (number: number) => {
            return Promise.resolve(sync_allBlocks[number]);
          },
          getBlockByBlockstamp: (blockstamp: string) => {
            return Promise.resolve(sync_allBlocks[parseInt(blockstamp)]);
          }
        });
        sync_bindex.push(HEAD);

        // Remember expiration dates
        for (const entry of index) {
          if (entry.expires_on) {
            sync_expires.push(entry.expires_on)
          }
          if (entry.revokes_on) {
            sync_expires.push(entry.revokes_on)
          }
        }
        sync_expires = _.uniq(sync_expires);

        await this.blockchain.createNewcomers(local_iindex, this.dal, this.logger)

        if (block.dividend
          || block.joiners.length
          || block.actives.length
          || block.revoked.length
          || block.excluded.length
          || block.certifications.length
          || block.transactions.length
          || block.medianTime >= sync_nextExpiring) {
          const nextExpiringChanged = block.medianTime >= sync_nextExpiring

          for (let i = 0; i < sync_expires.length; i++) {
            let expire = sync_expires[i];
            if (block.medianTime >= expire) {
              sync_expires.splice(i, 1);
              i--;
            }
          }
          sync_nextExpiring = sync_expires.reduce((max, value) => max ? Math.min(max, value) : value, 9007199254740991); // Far far away date

          // Fills in correctly the SINDEX
          await Promise.all(_.where(sync_sindex.concat(local_sindex), { op: 'UPDATE' }).map(async (entry: any) => {
            if (!entry.conditions) {
              const src = await this.dal.sindexDAL.getSource(entry.identifier, entry.pos);
              entry.conditions = src.conditions;
            }
          }))

          // Flush the INDEX (not bindex, which is particular)
          await this.dal.mindexDAL.insertBatch(sync_mindex);
          await this.dal.iindexDAL.insertBatch(sync_iindex);
          await this.dal.sindexDAL.insertBatch(sync_sindex);
          await this.dal.cindexDAL.insertBatch(sync_cindex);
          sync_iindex = local_iindex
          sync_cindex = local_cindex
          sync_mindex = local_mindex
          sync_sindex = local_sindex

          sync_sindex = sync_sindex.concat(await Indexer.ruleIndexGenDividend(HEAD, local_iindex, this.dal));
          sync_sindex = sync_sindex.concat(await Indexer.ruleIndexGarbageSmallAccounts(HEAD, sync_sindex, sync_memoryDAL));
          if (nextExpiringChanged) {
            sync_cindex = sync_cindex.concat(await Indexer.ruleIndexGenCertificationExpiry(HEAD, this.dal));
            sync_mindex = sync_mindex.concat(await Indexer.ruleIndexGenMembershipExpiry(HEAD, this.dal));
            sync_iindex = sync_iindex.concat(await Indexer.ruleIndexGenExclusionByMembership(HEAD, sync_mindex, this.dal));
            sync_iindex = sync_iindex.concat(await Indexer.ruleIndexGenExclusionByCertificatons(HEAD, sync_cindex, local_iindex, this.conf, this.dal));
            sync_mindex = sync_mindex.concat(await Indexer.ruleIndexGenImplicitRevocation(HEAD, this.dal));
          }
          // Update balances with UD + local garbagings
          await this.blockchain.updateWallets(sync_sindex, sync_memoryDAL)

          // Flush the INDEX again (needs to be done *before* the update of wotb links because of block#0)
          await this.dal.iindexDAL.insertBatch(sync_iindex);
          await this.dal.mindexDAL.insertBatch(sync_mindex);
          await this.dal.sindexDAL.insertBatch(sync_sindex);
          await this.dal.cindexDAL.insertBatch(sync_cindex);
//.........這裏部分代碼省略.........
開發者ID:duniter,項目名稱:duniter,代碼行數:101,代碼來源:QuickSync.ts


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