本文整理汇总了TypeScript中src/utils/fast.fastMap函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fastMap函数的具体用法?TypeScript fastMap怎么用?TypeScript fastMap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fastMap函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
export const filterTableColumns = (
data: string[][],
fieldOptions: FieldOption[]
): string[][] => {
const visibility = {}
const filteredData = fastMap<string[], string[]>(data, (row, i) => {
return fastFilter<string>(row, (col, j) => {
if (i === 0) {
const foundField = fieldOptions.find(
field => field.internalName === col
)
visibility[j] = foundField ? foundField.visible : true
}
return visibility[j]
})
})
return filteredData[0].length ? filteredData : [[]]
}
示例2: Set
export const sortTableData = (
data: string[][],
sort: SortOptions
): {sortedData: string[][]; sortedTimeVals: string[]} => {
const headerSet = new Set(data[0])
let sortIndex = 0
if (headerSet.has(sort.field)) {
sortIndex = _.indexOf(data[0], sort.field)
}
const dataValues = _.drop(data, 1)
const sortedData = [
data[0],
..._.orderBy<string[][]>(dataValues, sortIndex, [sort.direction]),
] as string[][]
const sortedTimeVals = fastMap<string[], string>(
sortedData,
(r: string[]): string => r[sortIndex]
)
return {sortedData, sortedTimeVals}
}