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


TypeScript object.keys函數代碼示例

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


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

示例1: it

  it("match between Python and bokehjs", () => {
    let fail_count = 0
    const all_view_model_names = concat([core_defaults.all_view_model_names(), widget_defaults.all_view_model_names()])
    for (const name of all_view_model_names) {
      const model = Models(name)
      const instance = new model({}, {silent: true, defer_initialization: true})
      const attrs = instance.attributes_as_json(true, deep_value_to_json)
      strip_ids(attrs)

      const python_defaults = get_defaults(name)
      const bokehjs_defaults = attrs
      if (!check_matching_defaults(name, python_defaults, bokehjs_defaults)) {
        console.log(name)
        // console.log('python defaults:')
        // console.log(python_defaults)
        // console.log('bokehjs defaults:')
        // console.log(bokehjs_defaults)
        console.log(difference(keys(python_defaults), keys(bokehjs_defaults)))
        fail_count += 1
      }
    }

    console.error(`Python/bokehjs matching defaults problems: ${fail_count}`)
    expect(fail_count).to.equal(0)
  })
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:25,代碼來源:defaults.ts

示例2: _hit_point

  protected _hit_point(geometry: PointGeometry): Selection {
    const result = hittest.create_empty_hit_test_result()
    const point = {x: geometry.sx, y: geometry.sy}
    let shortest = 9999

    const hits: {[key: string]: number[]} = {}
    for (let i = 0, end = this.sxs.length; i < end; i++) {
      const threshold = Math.max(2, this.visuals.line.cache_select('line_width', i) / 2)
      let points = null
      for (let j = 0, endj = this.sxs[i].length-1; j < endj; j++) {
        const p0 = {x: this.sxs[i][j],   y: this.sys[i][j]  }
        const p1 = {x: this.sxs[i][j+1], y: this.sys[i][j+1]}
        const dist = hittest.dist_to_segment(point, p0, p1)
        if (dist < threshold && dist < shortest) {
          shortest = dist
          points = [j]
        }
      }
      if (points)
        hits[i] = points
    }

    result.indices = keys(hits).map((x) => parseInt(x, 10))
    result.multiline_indices = hits

    return result
  }
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:27,代碼來源:multi_line.ts

示例3: _hit_span

  protected _hit_span(geometry: SpanGeometry): Selection {
    const {sx, sy} = geometry
    const result = hittest.create_empty_hit_test_result()

    let val: number
    let values: Arrayable<Arrayable<number>>
    if (geometry.direction === 'v') {
      val = this.renderer.yscale.invert(sy)
      values = this._ys
    } else {
      val = this.renderer.xscale.invert(sx)
      values = this._xs
    }

    const hits: {[key: string]: number[]} = {}
    for (let i = 0, end = values.length; i < end; i++) {
      const points = []
      for (let j = 0, endj = values[i].length-1; j < endj; j++) {
        if (values[i][j] <= val && val <= values[i][j+1])
          points.push(j)
      }
      if (points.length > 0)
        hits[i] = points
    }

    result.indices = keys(hits).map((x) => parseInt(x, 10))
    result.multiline_indices = hits

    return result
  }
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:30,代碼來源:multi_line.ts

示例4: it

 it("have all view models from Python in registered locations", () => {
   const registered: {[key: string]: boolean} = {}
   for (const name of Models.registered_names()) {
     registered[name] = true
   }
   const missing = []
   const all_view_model_names = concat([keys(models_defaults), keys(widget_defaults)])
   for (const name of all_view_model_names) {
     if (!(name in registered)) {
       missing.push(name)
     }
   }
   for (const m of missing) {
     console.log(`'base.locations["${m}"]' not found but there's a Python model '${m}'`)
   }
   expect(missing.length).to.equal(0)
 })
開發者ID:jsignell,項目名稱:bokeh,代碼行數:17,代碼來源:defaults.ts

示例5: expect

 it.skip("have all non-Widget view models from Python in the Models object", () => {
   const missing = []
   for (const name of keys(models_defaults)) {
     if (!(name in Models.registered_names())) {
       missing.push(name)
     }
   }
   for (const m of missing) {
     console.log(`'Models.${m}' not found but there's a Python model '${m}'`)
   }
   expect(missing.length).to.equal(0)
 })
開發者ID:jsignell,項目名稱:bokeh,代碼行數:12,代碼來源:defaults.ts

示例6: attributes_as_json

  attributes_as_json(include_defaults: boolean = true, value_to_json = ColumnDataSource._value_to_json): any {
    const attrs: {[key: string]: any} = {}
    const obj = this.serializable_attributes()
    for (const key of keys(obj)) {
      let value = obj[key]
      if (key === 'data')
        value = encode_column_data(value, this._shapes)

      if (include_defaults)
        attrs[key] = value
      else if (key in this._set_after_defaults)
        attrs[key] = value
    }
    return value_to_json("attributes", attrs, this)
  }
開發者ID:jsignell,項目名稱:bokeh,代碼行數:15,代碼來源:column_data_source.ts

示例7: build_levels

  build_levels(): void {
    const renderer_models = this.model.plot.all_renderers

    // should only bind events on NEW views
    const old_renderers = keys(this.renderer_views)
    const new_renderer_views = build_views(this.renderer_views, renderer_models, this.view_options()) as RendererView[]
    const renderers_to_remove = difference(old_renderers, renderer_models.map((model) => model.id))

    for (const id_ of renderers_to_remove) {
      delete this.levels.glyph[id_]
    }

    for (const view of new_renderer_views) {
      this.levels[view.model.level][view.model.id] = view
    }
  }
開發者ID:keyurspatel,項目名稱:bokeh,代碼行數:16,代碼來源:plot_canvas.ts

示例8: it

 it("should have 3 entries", () => {
   expect(keys(tmpl.DEFAULT_FORMATTERS).length).to.be.equal(3)
 })
開發者ID:,項目名稱:,代碼行數:3,代碼來源:

示例9: _make_transform

 protected _make_transform(val: string, fn: string): Function {
   // this relies on keys(args) and values(args) returning keys and values
   // in the same order
   return new Function(...keys(this.args), val, "require", "exports", fn)
 }
開發者ID:Zyell,項目名稱:bokeh,代碼行數:5,代碼來源:customjs_transform.ts


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