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


TypeScript types.isTypedArray函數代碼示例

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


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

示例1: map_data

  map_data(): void {
    const self = this as any

    for (let [xname, yname] of this.model._coords) {
      const sxname = `s${xname}`
      const syname = `s${yname}`
      xname = `_${xname}`
      yname = `_${yname}`

      if (self[xname] != null && (isArray(self[xname][0]) || isTypedArray(self[xname][0]))) {
        const ni = self[xname].length

        self[sxname] = new Array(ni)
        self[syname] = new Array(ni)

        for (let i = 0; i < ni; i++) {
          const nj = self[xname][i].length
          self[sxname][i] = new Array(nj)
          self[syname][i] = new Array(nj)
          for (let j = 0; j < nj; j++) {
            const nk = self[xname][i][j].length
            self[sxname][i][j] = new Array(nk)
            self[syname][i][j] = new Array(nk)
            for (let k = 0; k < nk; k++) {
              const [sx, sy] = this.map_to_screen(self[xname][i][j][k], self[yname][i][j][k])
              self[sxname][i][j][k] = sx
              self[syname][i][j][k] = sy
            }
          }
        }
      }
    }
  }
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:33,代碼來源:multi_polygons.ts

示例2: stream_to_column

export function stream_to_column(col: Arrayable, new_col: Arrayable, rollover?: number): Arrayable {
  if (isArray(col)) {
    const result = col.concat(new_col)

    if (rollover != null && result.length > rollover)
      return result.slice(-rollover)
    else
      return result
  } else if (isTypedArray(col)) {
    const total_len = col.length + new_col.length

    // handle rollover case for typed arrays
    if (rollover != null && total_len > rollover) {
      const start = total_len - rollover
      const end = col.length

      // resize col if it is shorter than the rollover length
      let result: TypedArray
      if (col.length < rollover) {
        result = new ((col as any).constructor)(rollover)
        result.set(col, 0)
      } else
        result = col

      // shift values in original col to accommodate new_col
      for (let i = start, endi = end; i < endi; i++) {
        result[i-start] = result[i]
      }

      // update end values in col with new_col
      for (let i = 0, endi = new_col.length; i < endi; i++) {
        result[i+(end-start)] = new_col[i]
      }

      return result
    } else {
      const tmp = new ((col as any).constructor)(new_col)
      return typed_array.concat(col, tmp)
    }
  } else
    throw new Error("unsupported array types")
}
開發者ID:jsignell,項目名稱:bokeh,代碼行數:42,代碼來源:column_data_source.ts


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