本文整理匯總了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;
}
});
示例2: getPerkNodesInColumn
function getPerkNodesInColumn(item: D1Item, column): D1GridNode[] {
if (!item.talentGrid) {
return [];
}
return _.where(item.talentGrid.nodes, { column });
}
示例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;
},
示例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);
}
})
示例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."
}
})
示例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
));
});
示例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();
}
示例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);
//.........這裏部分代碼省略.........