本文整理汇总了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();
});
示例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
));
});
示例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 };
}
示例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;
}
});
示例5: Number
vm.lockedperks[type] = _.omit(perkMap, (_perk, perkHash) => {
return _.findWhere(vendorPerks[vm.active][type], { hash: Number(perkHash) });
});
示例6: alreadyExists
function alreadyExists(set: D1Item[], id: string) {
return _.findWhere(set, { id }) || _.findWhere(set, { index: id });
}
示例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
);
}
示例8: getKonteynerById
getKonteynerById(id: number): IKonteyner {
return _.findWhere(this.bkgModel.konteynerlar, { id: id });
}
示例9: type
data.relationships[relationshipName].data.forEach((item: any) => {
let relationship: any = _.findWhere(included, {id: item.id});
relationshipList.push(new type(relationship));
});
示例10:
_.each(results, (trigger) => {
let o = _.findWhere(timeline, { id: trigger.id })
if (o) {
o.trigger.value = trigger.time
}
})