本文整理汇总了TypeScript中Immutable.List.reduce方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.reduce方法的具体用法?TypeScript List.reduce怎么用?TypeScript List.reduce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.reduce方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: transform
transform(tasks: List<Task>): List<string> {
const owners = tasks.reduce((result, task) =>
result.includes(task.owner) ?
result : result.push(task.owner),
List<string>());
return owners;
}
示例2: process
process(rawData: RawTableData): TableData {
const data = (rawData instanceof Iterable)
? rawData as Iterable<number, any>
: Seq(rawData)
return this.plugins.reduce(
(result, plugin) => plugin.process(result, this.columns),
data
)
}
示例3: getValue
getValue(): number {
let totalValueOfPrescriptions = this.prescriptions.reduce(
(acc, prescription) => acc + prescription.value,
0
);
if (this.isGrantedLimitExemption) {
return totalValueOfPrescriptions;
}
return Math.min(totalValueOfPrescriptions, 30);
}
示例4: comparator
const sorted = tableData.sort((row1, row2) => {
const reducer = (result: number, sorter: TableSorter) => {
const { selector, comparator } = sorter
const order = this.getSortOrder(sorter.order)
const factor = order === DESC ? -1 : 1
return result !== 0
? result
: comparator(selector(row1), selector(row2)) * factor
}
return sorters.reduce(reducer, 0)
})
示例5: sum_list
function sum_list(list: List<number>): number {
return list.reduce((acc: number, n: number) => acc + n, 0);
}