當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript array.all函數代碼示例

本文整理匯總了TypeScript中core/util/array.all函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript all函數的具體用法?TypeScript all怎麽用?TypeScript all使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了all函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _init

  protected _init(): void {
    let levels: number
    let inside_padding: number
    if (all(this.factors as any, isString)) {
      levels = 1;
      [this._mapping, inside_padding] = map_one_level(this.factors as string[], this.factor_padding)
    } else if (all(this.factors as any, (x) => isArray(x) && x.length == 2 && isString(x[0]) && isString(x[1]))) {
      levels = 2;
      [this._mapping, this.tops, inside_padding] = map_two_levels(this.factors as [string, string][], this.group_padding, this.factor_padding)
    } else if (all(this.factors as any, (x) => isArray(x) && x.length == 3  && isString(x[0]) && isString(x[1]) && isString(x[2]))) {
      levels = 3;
      [this._mapping, this.tops, this.mids, inside_padding] = map_three_levels(this.factors as [string, string, string][], this.group_padding, this.subgroup_padding, this.factor_padding)
    } else
      throw new Error("???")

    let start = 0
    let end = this.factors.length + inside_padding

    if (this.range_padding_units == "percent") {
      const half_span = (end - start) * this.range_padding / 2
      start -= half_span
      end += half_span
    } else {
      start -= this.range_padding
      end += this.range_padding
    }

    this.setv({start: start, end: end, levels: levels}, {silent: true})

    if (this.bounds == "auto")
      this.setv({bounds: [start, end]}, {silent: true})
  }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:32,代碼來源:factor_range.ts

示例2: compute_indices

 compute_indices(_source): any {
   if ((this.filter != null ? this.filter.length : undefined) >= 0) {
     if (all(this.filter, isBoolean)) {
       return (range(0, this.filter.length).filter((i) => this.filter[i] === true));
     } else if (all(this.filter, isInteger)) {
       return this.filter;
     } else {
       logger.warn(`Filter ${this.id}: filter should either be array of only booleans or only integers, defaulting to no filtering`);
       return null;
     }
   } else {
     logger.warn(`Filter ${this.id}: filter was not set to be an array, defaulting to no filtering`);
     return null;
   }
 }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:15,代碼來源:filter.ts

示例3: compute_indices

 compute_indices(_source: DataSource): number[] | null {
   if (this.indices != null && this.indices.length >= 0) {
     if (all(this.indices, isInteger))
       return this.indices
     else {
       logger.warn(`IndexFilter ${this.id}: indices should be array of integers, defaulting to no filtering`)
       return null
     }
   } else {
     logger.warn(`IndexFilter ${this.id}: indices was not set, defaulting to no filtering`)
     return null
   }
 }
開發者ID:Zyell,項目名稱:bokeh,代碼行數:13,代碼來源:index_filter.ts

示例4: compute_indices

 compute_indices(_source): any {
   if ((this.indices != null ? this.indices.length : undefined) >= 0) {
     if (all(this.indices, isInteger)) {
       return this.indices;
     } else {
       logger.warn(`IndexFilter ${this.id}: indices should be array of integers, defaulting to no filtering`);
       return null;
     }
   } else {
     logger.warn(`IndexFilter ${this.id}: indices was not set, defaulting to no filtering`);
     return null;
   }
 }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:13,代碼來源:index_filter.ts

示例5: compute_indices

 compute_indices(source: ColumnarDataSource): number[] | null {
   const booleans = this.booleans
   if (booleans != null && booleans.length > 0) {
     if (all(booleans, isBoolean)) {
       if (booleans.length !== source.get_length()) {
         logger.warn(`BooleanFilter ${this.id}: length of booleans doesn't match data source`)
       }
       return range(0, booleans.length).filter((i) => booleans[i] === true)
     } else {
       logger.warn(`BooleanFilter ${this.id}: booleans should be array of booleans, defaulting to no filtering`)
       return null
     }
   } else {
     if (booleans != null && booleans.length == 0)
       logger.warn(`BooleanFilter ${this.id}: booleans is empty, defaulting to no filtering`)
     else
       logger.warn(`BooleanFilter ${this.id}: booleans was not set, defaulting to no filtering`)
     return null
   }
 }
開發者ID:Zyell,項目名稱:bokeh,代碼行數:20,代碼來源:boolean_filter.ts

示例6: compute_indices

 compute_indices(source): any {
   if ((this.booleans != null ? this.booleans.length : undefined) > 0) {
     if (all(this.booleans, isBoolean)) {
       if (this.booleans.length !== source.get_length()) {
         logger.warn(`BooleanFilter ${this.id}: length of booleans doesn't match data source`);
       }
       return (range(0, this.booleans.length).filter((i) => this.booleans[i] === true));
     } else {
       logger.warn(`BooleanFilter ${this.id}: booleans should be array of booleans, defaulting to no filtering`);
       return null;
     }
   } else {
     if ((this.booleans != null ? this.booleans.length : undefined) === 0) {
       logger.warn(`BooleanFilter ${this.id}: booleans is empty, defaulting to no filtering`);
     } else {
       logger.warn(`BooleanFilter ${this.id}: booleans was not set, defaulting to no filtering`);
     }
     return null;
   }
 }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:20,代碼來源:boolean_filter.ts

示例7: switch

 const active = (() => { switch (this.model.click_policy) {
   case "none": return true
   case "hide": return all(item.renderers, r => r.visible)
   case "mute": return all(item.renderers, r => !r.muted)
 } })()
開發者ID:,項目名稱:,代碼行數:5,代碼來源:


注:本文中的core/util/array.all函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。