當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。