本文整理汇总了TypeScript中common/helpers/group-id-by.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateCommonsNowThrows
async function updateCommonsNowThrows(store: IStore) {
if (!store.getState().setup.done) {
return;
}
const { caves, downloadKeys, installLocations } = await call(
messages.FetchCommons,
{}
);
let locationSizes = {};
if (!isEmpty(installLocations)) {
for (const x of installLocations) {
locationSizes[x.id] = x.sizeInfo.installedSize;
}
}
push(store, {
caves: indexBy(caves, "id"),
caveIdsByGameId: groupIdBy(caves, "gameId"),
downloadKeys: indexBy(downloadKeys, "id"),
downloadKeyIdsByGameId: groupIdBy(downloadKeys, "gameId"),
locationSizes,
});
}
示例2: it
it("groupIdBy", () => {
assert.deepEqual(groupIdBy(null, "gameId"), {});
assert.deepEqual(groupIdBy(undefined, "gameId"), {});
assert.deepEqual(groupIdBy([], "gameId"), {});
assert.deepEqual(groupIdBy({}, "gameId"), {});
const items = [
{ id: 1, gameId: 11 },
{ id: 4, gameId: 44 },
{ id: 7, gameId: 77 },
{ id: 77, gameId: 77 },
];
assert.deepEqual(groupIdBy(items, "gameId"), {
11: [1],
44: [4],
77: [7, 77],
} as any);
assert.deepEqual(
groupIdBy<typeof items[0]>(items, o => String(o.gameId * 10)),
{
110: [1],
440: [4],
770: [7, 77],
} as any
);
assert.deepEqual(groupIdBy(items, "id"), {
1: [1],
4: [4],
7: [7],
77: [77],
} as any);
const itemMap = indexBy(items, "id");
assert.deepEqual(groupIdBy(itemMap, "gameId"), {
11: [1],
44: [4],
77: [7, 77],
} as any);
assert.deepEqual(groupIdBy(itemMap, "id"), {
1: [1],
4: [4],
7: [7],
77: [77],
} as any);
});
示例3: String
itemIdsByGameId: (state: IDownloadsState) =>
groupIdBy<Download>(state.items, i => String(i.game && i.game.id)),