当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript array.uniq函数代码示例

本文整理汇总了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 []
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:26,代码来源:legend_item.ts

示例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;
 })());
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:7,代码来源:graph_hit_test_policy.ts

示例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
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:17,代码来源:graph_hit_test_policy.ts

示例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)
      }
    }
  }
开发者ID:gully,项目名称:bokeh,代码行数:20,代码来源:columnar_data_source.ts

示例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 [];
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:24,代码来源:legend_item.ts


注:本文中的core/util/array.uniq函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。