本文整理汇总了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)
})
示例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
}
示例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
}
示例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)
})
示例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)
})
示例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)
}
示例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
}
}
示例8: it
it("should have 3 entries", () => {
expect(keys(tmpl.DEFAULT_FORMATTERS).length).to.be.equal(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)
}