本文整理汇总了TypeScript中Immutable.List.toJS方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.toJS方法的具体用法?TypeScript List.toJS怎么用?TypeScript List.toJS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.toJS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: searchAnnotations
function searchAnnotations(search: string|null, annotations: List<Record<AnnotationColorMap>>) {
if(search !== null) {
const jsAnnotations = annotations.toJS()
const fuse = new Fuse(jsAnnotations, _FUSE_OPTIONS_)
const res: string[] = fuse.search(search)
return annotations.filter(ann => {
const aId = ann.getIn(['annotation', 'id'])
return res.find(id => parseInt(id) === aId)
})
} else {
return annotations
}
}
示例2: process
/**
* Function that intented to be used by the table plugin manager to
* perform the sorting process. It supports sorting with mutiple sorter,
* which will be performed in ASC order.
*
* NOTE: the sorting process will short circuit on any non-zero sorter
* result.
*/
process(tableData: TableData, columns: List<ColumnDef>) {
const columnSorters: Iterable<number, TableSorter> = columns
.filterNot(s => _.isUndefined(s.sortable))
.map(columnDef => {
const sorter = columnDef.sortable
const selector = columnDef.field
const type = columnDef.type
const order = sorter.order
const comparator = sorter.comparator || this.getComparator(type)
return { order, selector, comparator }
})
const sorters = this.sorters.concat(columnSorters)
.filter(s => this.getSortOrder(s.order) !== NONE)
if (sorters.size > 1 && !this.multiSortable) {
if (process.env.NODE_ENV === 'development') {
throw new Error(`[RCBOX] Found multiple sorter enabled while this` +
`feature is disabled. To enable this feature, set 'multiSortable' ` +
`property to 'true' on TableSortPlugin. Those unexpected sorters ` +
`are: ${sorters.toJS()}`)
}
// NOTE: Returns unsorted table data as fallback to avoid uncertain
// data will be used in production environment.
return tableData
}
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)
})
return sorted
}
示例3: h
(tagName: string,
options: VirtualDOM.createProperties,
children: List<VirtualDOM.VNode>): VirtualDOM.VNode => (
h(tagName, options, children.toJS())
);