本文整理汇总了TypeScript中core/util/array.uniq函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniq函数的具体用法?TypeScript uniq怎么用?TypeScript uniq使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniq函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: get_labels_list_from_label_prop
get_labels_list_from_label_prop(): string[] {
// Always return a list of the labels
if (isValue<string | null>(this.label)) {
const {value} = this.label
return value != null ? [value] : []
}
const field = this.get_field_from_label_prop()
if (field != null) {
let source: ColumnarDataSource
if (this.renderers[0] && this.renderers[0].data_source != null)
source = this.renderers[0].data_source
else
return ["No source found"]
if (source instanceof ColumnarDataSource) {
const data = source.get_column(field)
if (data != null)
return uniq(Array.from(data))
else
return ["Invalid field"]
}
}
return []
}
示例2:
const node_indices = ((() => {
const result = [];
for (const i of uniq(nodes)) {
result.push(node_view.model.data_source.data.index.indexOf(i));
}
return result;
})());
示例3: get_linked_nodes
get_linked_nodes(node_source: ColumnarDataSource, edge_source: ColumnarDataSource, mode: string): Selection {
let edge_indices: number[] = []
if(mode == 'selection')
edge_indices = edge_source.selected.indices
else if (mode == 'inspection')
edge_indices = edge_source.inspected.indices
const nodes = []
for(const i of edge_indices){
nodes.push(edge_source.data.start[i])
nodes.push(edge_source.data.end[i])
}
const node_indices = uniq(nodes).map((i) => indexOf(node_source.data.index, i))
const linked_nodes = create_empty_hit_test_result()
linked_nodes.indices = node_indices
return linked_nodes
}
示例4: get_length
get_length(soft: boolean = true): number | null {
const lengths = uniq(values(this.data).map((v) => v.length))
switch (lengths.length) {
case 0: {
return null // XXX: don't guess, treat on case-by-case basis
}
case 1: {
return lengths[0]
}
default: {
const msg = "data source has columns of inconsistent lengths"
if (soft) {
logger.warn(msg)
return lengths.sort()[0]
} else
throw new Error(msg)
}
}
}
示例5: get_labels_list_from_label_prop
get_labels_list_from_label_prop() {
// Always return a list of the labels
if ((this.label != null) && (this.label.value != null)) {
return [this.label.value];
}
const field = this.get_field_from_label_prop();
if (field != null) {
let source;
if (this.renderers[0] && (this.renderers[0].data_source != null)) {
source = this.renderers[0].data_source;
} else {
return ["No source found"];
}
if (source instanceof ColumnDataSource) {
const data = source.get_column(field);
if (data != null) {
return uniq(data);
} else {
return ["Invalid field"];
}
}
}
return [];
}