• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript types.isString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中core/util/types.isString函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isString函数的具体用法?TypeScript isString怎么用?TypeScript isString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isString函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: _add_attribution

  protected _add_attribution(): void {
    const { attribution } = this.model.tile_source

    if (isString(attribution) && (attribution.length > 0)) {
      if ((this.attributionEl == null)) {
        const right = this.plot_model.canvas._right.value - this.plot_model.frame._right.value
        const bottom = this.plot_model.canvas._bottom.value - this.plot_model.frame._bottom.value
        const max_width = this.map_frame._width.value
        this.attributionEl = div({
          class: 'bk-tile-attribution',
          style: {
            position: "absolute",
            bottom: `${bottom}px`,
            right: `${right}px`,
            'max-width': `${max_width}px`,
            padding: "2px",
            'background-color': 'rgba(255,255,255,0.8)',
            'font-size': '9pt',
            'font-family': 'sans-serif',
          },
        })

        const overlays = this.plot_view.canvas_view.events_el
        overlays.appendChild(this.attributionEl)
      }

      this.attributionEl.innerHTML = attribution
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:29,代码来源:tile_renderer.ts


示例2: _add_attribution

  protected _add_attribution(): void {
    const {attribution} = this.model.tile_source

    if (isString(attribution) && attribution.length > 0) {
      if (this.attributionEl == null) {
        const right = this.plot_model.canvas._right.value - this.plot_model.frame._right.value
        const bottom = this.plot_model.canvas._bottom.value - this.plot_model.frame._bottom.value
        const max_width = this.map_frame._width.value
        this.attributionEl = div({
          class: 'bk-tile-attribution',
          style: {
            position: "absolute",
            bottom: `${bottom}px`,
            right: `${right}px`,
            'max-width': `${max_width - 4 /*padding*/}px`,
            padding: "2px",
            'background-color': 'rgba(255,255,255,0.5)',
            'font-size': '7pt',
            'font-family': 'sans-serif',
            'line-height': '1.05',
            'white-space': 'nowrap',
            overflow: 'hidden',
            'text-overflow': 'ellipsis',
          },
        })

        const overlays = this.plot_view.canvas_view.events_el
        overlays.appendChild(this.attributionEl)
      }

      this.attributionEl.innerHTML = attribution
      this.attributionEl.title = this.attributionEl.textContent!.replace(/\s*\n\s*/g, " ")
    }
  }
开发者ID:,项目名称:,代码行数:34,代码来源:


示例3: _run_suite

  async function _run_suite(suite: Suite, seq: Suite[]) {
    for (const sub_suite of suite.suites) {
      await _run_suite(sub_suite, seq.concat(sub_suite))
    }

    for (const test of suite.tests) {
      const {fn, description} = test

      if (grep != null) {
        const descriptions = seq.map((s) => s.description).concat(description)

        if (isString(grep)) {
          if (!descriptions.some((d) => d.includes(grep)))
            continue
        } else {
          if (!descriptions.some((d) => d.search(grep) != -1))
            continue
        }
      }

      current_test = test
      await fn()
      current_test = null
    }
  }
开发者ID:jsignell,项目名称:bokeh,代码行数:25,代码来源:framework.ts


示例4: if

export function cat_v_compute<T>(data: ArrayableOf<Factor>, factors: ArrayableOf<Factor>,
    targets: Arrayable<T>, values: Arrayable<T>, start: number, end: number, extra_value: T): void {

  for (let i = 0, N = data.length; i < N; i++) {
    let d = data[i]

    let key: number
    if (isString(d))
      key = index_of(factors as Arrayable<L1Factor>, d)
    else {
      if (start != null) {
        if (end != null)
          d = d.slice(start, end) as Factor
        else
          d = d.slice(start) as Factor
      } else if (end != null)
        d = d.slice(0, end) as Factor

      if (d.length == 1)
        key = index_of(factors as Arrayable<L1Factor>, d[0])
      else
        key = find_index(factors as Arrayable<L2Factor | L3Factor>, (x) => _cat_equals(x, d))
    }

    let value: T
    if (key < 0 || key >= targets.length)
      value = extra_value
    else
      value = targets[key]

    values[i] = value
  }
}
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:33,代码来源:categorical_mapper.ts


示例5: _get_values

  // XXX: not really string[], but Factor[]. This needs to be clarified across the repo.
  _get_values(data: string[], palette: number[], _image_glyph: boolean = false): number[] {
    const values = [];

    for (let d of data) {
      let color, key;

      if (isString(d)) {
        key = this.factors.indexOf(d);
      } else {
        if (this.start != null) {
          if (this.end != null) {
            d = d.slice(this.start, this.end);
          } else {
            d = d.slice(this.start);
          }
        } else if (this.end != null) {
          d = d.slice(0, this.end);
        }
        if (d.length === 1) {
          key = this.factors.indexOf(d[0]);
        } else {
          key = findIndex(this.factors, x => _equals(x, d));
        }
      }

      if ((key < 0) || (key >= palette.length)) {
        color = this.nan_color;
      } else {
        color = palette[key];
      }

      values.push(color);
    }
    return values;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:36,代码来源:categorical_color_mapper.ts


示例6: if

  protected _v_compute<T>(data: Arrayable<Factor>, values: Arrayable<T>,
      palette: Arrayable<T>, {nan_color}: {nan_color: T}): void {

    for (let i = 0, end = data.length; i < end; i++) {
      let d = data[i]

      let key: number
      if (isString(d))
        key = this.factors.indexOf(d)
      else {
        if (this.start != null) {
          if (this.end != null)
            d = d.slice(this.start, this.end) as Factor
          else
            d = d.slice(this.start) as Factor
        } else if (this.end != null)
          d = d.slice(0, this.end) as Factor

        if (d.length == 1)
          key = this.factors.indexOf(d[0])
        else
          key = findIndex(this.factors, (x) => _equals(x, d))
      }

      let color: T
      if (key < 0 || key >= palette.length)
        color = nan_color
      else
        color = palette[key]

      values[i] = color
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:33,代码来源:categorical_color_mapper.ts


示例7: compute_legend_location

  compute_legend_location() {
    let sx, sy;
    const legend_dimensions = this.compute_legend_dimensions();
    const [legend_height, legend_width] = [legend_dimensions.height, legend_dimensions.width];

    const legend_margin = this.model.margin;

    const panel = this.model.panel != null ? this.model.panel : this.plot_view.frame;
    const [hr, vr] = panel.bbox.ranges;

    const { location } = this.model;
    if (isString(location)) {
      switch (location) {
        case 'top_left':
          sx = hr.start + legend_margin;
          sy = vr.start + legend_margin;
          break;
        case 'top_center':
          sx = ((hr.end + hr.start)/2) - (legend_width/2);
          sy = vr.start + legend_margin;
          break;
        case 'top_right':
          sx = hr.end - legend_margin - legend_width;
          sy = vr.start + legend_margin;
          break;
        case 'bottom_right':
          sx = hr.end - legend_margin - legend_width;
          sy = vr.end - legend_margin - legend_height;
          break;
        case 'bottom_center':
          sx = ((hr.end + hr.start)/2) - (legend_width/2);
          sy = vr.end - legend_margin - legend_height;
          break;
        case 'bottom_left':
          sx = hr.start + legend_margin;
          sy = vr.end - legend_margin - legend_height;
          break;
        case 'center_left':
          sx = hr.start + legend_margin;
          sy = ((vr.end + vr.start)/2) - (legend_height/2);
          break;
        case 'center':
          sx = ((hr.end + hr.start)/2) - (legend_width/2);
          sy = ((vr.end + vr.start)/2) - (legend_height/2);
          break;
        case 'center_right':
          sx = hr.end - legend_margin - legend_width;
          sy = ((vr.end + vr.start)/2) - (legend_height/2);
          break;
      }
    } else if (isArray(location) && (location.length === 2)) {
      const [vx, vy] = location;
      sx = panel.xview.compute(vx);
      sy = panel.yview.compute(vy) - legend_height;
    }

    return {sx, sy};
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:58,代码来源:color_bar.ts


示例8: _render_seq

  _render_seq(ctx: Context2d, seq: (Draw | number)[]): void {
    let c: Draw = "M"
    let p = [0, 0]
    let i = 0

    while (i < seq.length) {
      if (isString(seq[i])) {
        c = seq[i] as Draw
        i += 1
      }

      switch (c) {
        case "M": {
          const [x, y] = seq.slice(i, i+2) as number[]
          ctx.moveTo(x, y)
          p = [x, y]
          i += 2
          break
        }
        case "L": {
          const [x, y] = seq.slice(i, i+2) as number[]
          ctx.lineTo(x, y)
          p = [x, y]
          i += 2
          break
        }
        case "C": {
          const [cx0, cy0, cx1, cy1, x, y] = seq.slice(i, i+6) as number[]
          ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)
          p = [x, y]
          i += 6
          break
        }
        case "Q": {
          const [cx0, cy0, x, y] = seq.slice(i, i+4) as number[]
          ctx.quadraticCurveTo(cx0, cy0, x, y)
          p = [x, y]
          i += 4
          break
        }
        case "A": {
          const [rx, ry, x_rotation, large_arc, sweep, x, y] = seq.slice(i, i+7) as number[]

          const [px, py] = p
          const segments = arc_to_bezier(px, py, rx, ry, -x_rotation, large_arc, 1 - sweep, x, y)

          for (const [cx0, cy0, cx1, cy1, x, y] of segments)
            ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)

          p = [x, y]
          i += 7
          break
        }
        default:
          throw new Error(`unexpected command: ${c}`)
      }
    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:58,代码来源:gear.ts


示例9: option

    const options = this.model.options.map((opt) => {
      let value, _label
      if (isString(opt))
        value = _label  = opt
      else
        [value, _label] = opt

      return option({value}, _label)
    })
开发者ID:,项目名称:,代码行数:9,代码来源:


示例10: option

    return values.map((el) => {
      let value, _label
      if (isString(el))
        value = _label  = el
      else
        [value, _label] = el

      const selected = this.model.value == value
      return option({selected: selected, value: value}, _label)
    })
开发者ID:Zyell,项目名称:bokeh,代码行数:10,代码来源:selectbox.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript types.isTypedArray函数代码示例发布时间:2022-05-25
下一篇:
TypeScript types.isStrictNaN函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap