本文整理汇总了TypeScript中ramda.indexBy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript indexBy函数的具体用法?TypeScript indexBy怎么用?TypeScript indexBy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了indexBy函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: parseRegions
function parseRegions(fileContent: string): RegionMap {
const questionRows: Row[] = parse(fileContent);
const regions = questionRows.slice(1).map(row => ({
id: row[0],
name: row[1]
}));
return R.indexBy(r => r.id, regions) as RegionMap;
}
示例2:
export const pageDTO = (page: Page): PageDTO => {
const translations = R.map(
R.prop('value'),
R.indexBy(R.prop('field'), page.translations),
);
return {
alias: page.alias,
title: translations.title,
content: translations.content,
}
}
示例3: getDataFields
return getDataFields(address).then(fields => {
const oracle = getProviderData(fields);
if (oracle.status === RESPONSE_STATUSES.ERROR) {
return null;
}
const assets = getProviderAssets(fields)
.filter(item => item.status === RESPONSE_STATUSES.OK)
.map(item => item.content) as Array<TProviderAsset>;
return {
oracle: oracle.content,
assets: indexBy<TProviderAsset>(prop('id'), assets)
};
});
示例4:
export const categoryDTO = (category: Category): CategoryDTO => {
const translations = R.map(
R.prop('value'),
R.indexBy(R.prop('field'), category.translations),
);
const children = category.children || [];
return {
name: category.name,
date: category.date,
title: translations.title,
featured: category.featured && category.featured.src,
description: translations.description,
children: children.map(categoryDTO),
}
}
示例5:
export const photoDTO = (photo: Photo): PhotoDTO => {
const translations = R.map(
R.prop('value'),
R.indexBy(R.prop('field'), photo.translations),
);
return {
src: photo.src,
views: photo.views,
width: photo.width,
height: photo.height,
group: photo.group,
datetime: photo.datetime,
description: translations.description,
}
}
示例6:
export const cardListFrom = (array: Array<Card>): CardContainer =>
R.indexBy<Card>(R.prop('id'), array);
示例7:
export const entitiesFrom = (array: Array<Character>): EntityContainer =>
R.indexBy<Character>(R.prop('id'), array);