本文整理汇总了TypeScript中core/util/types.isObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isObject函数的具体用法?TypeScript isObject怎么用?TypeScript isObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isObject函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _value_to_json
static _value_to_json(key, value, optional_parent_object) {
if (isObject(value) && (key === 'data')) {
return serialization.encode_column_data(value, optional_parent_object._shapes)
} else {
return HasProps._value_to_json(key, value, optional_parent_object)
}
}
示例2: function
export const slice = function(ind, length) {
let ref, start, step, stop
if (isObject(ind)) {
return [ind.start != null ? ind.start : 0, ind.stop != null ? ind.stop : length, ind.step != null ? ind.step : 1]
}
return [start, stop, step] = ref = [ind, ind+1, 1], ref
}
示例3: it
it(`should roundtrip ${typ.name} arrays`, () => {
const array = new typ([1, 2])
const shape = [2]
const e = ser.encode_base64(array, shape)
expect(isObject(e)).to.be.true
expect(Object.keys(e).length).to.be.equal(3)
expect(e.dtype).to.equal(ser.DTYPES[typ.name as ser.ArrayName])
expect(e.shape).to.be.deep.equal([2])
const [d, s] = ser.decode_base64(e)
expect(array).to.be.deep.equal(d)
expect(shape).to.be.deep.equal(s)
})
示例4: strip_ids
function strip_ids(value: any): void {
if (isArray(value)) {
for (const v of value) {
strip_ids(v)
}
} else if (isObject(value)) {
if ('id' in value) {
delete value.id
}
for (const k in value) {
strip_ids(value[k])
}
}
}
示例5: deep_value_to_json
function deep_value_to_json(_key: string, value: any, _optional_parent_object: any): any {
if (value instanceof HasProps) {
return {type: value.type, attributes: value.attributes_as_json()}
} else if (isArray(value)) {
const ref_array: any[] = []
for (let i = 0; i < value.length; i++) {
ref_array.push(deep_value_to_json(i.toString(), value[i], value))
}
return ref_array
} else if (isObject(value)) {
const ref_obj: {[key: string]: any} = {}
for (const subkey in value) {
if (value.hasOwnProperty(subkey))
ref_obj[subkey] = deep_value_to_json(subkey, value[subkey], value)
}
return ref_obj
} else
return value
}
示例6: check_matching_defaults
function check_matching_defaults(name: string, python_defaults: {[key: string]: any}, bokehjs_defaults: {[key: string]: any}): boolean {
const different: string[] = []
const python_missing: string[] = []
const bokehjs_missing: string[] = []
for (const k in bokehjs_defaults) {
const js_v = bokehjs_defaults[k]
// special case for graph renderer node_renderer
if (name === "GraphRenderer" && k === "node_renderer")
continue
// special case for graph renderer node_renderer
if (name === "GraphRenderer" && k === "edge_renderer")
continue
// special case for date picker, default is "now"
if (name === 'DatePicker' && k === 'value')
continue
// special case for date time tickers, class hierarchy and attributes are handled differently
if (name === "DatetimeTicker" && k === "tickers")
continue
// special case for Title derived text properties
if (name === "Title" && (k === "text_align" || k === "text_baseline"))
continue
// special case for selections that have a method added to them
if (k === 'selected')
delete js_v['0d'].get_view
if (k === 'id')
continue
if (k in python_defaults) {
let py_v = python_defaults[k]
strip_ids(py_v)
if (!isEqual(py_v, js_v)) {
// these two conditionals compare 'foo' and {value: 'foo'}
if (isObject(js_v) && 'value' in js_v && isEqual(py_v, js_v['value']))
continue
if (isObject(py_v) && 'value' in py_v && isEqual(py_v['value'], js_v))
continue
if (isObject(js_v) && 'attributes' in js_v && isObject(py_v) && 'attributes' in py_v) {
if (js_v['type'] === py_v['type']) {
check_matching_defaults(`${name}.${k}`, py_v['attributes'], js_v['attributes'])
continue
}
}
// compare arrays of objects
if (isArray(js_v) && isArray(py_v)) {
let equal = true
// palettes in JS are stored as int color values
if (k === 'palette')
py_v = py_v.map((x: string) => parseInt(x.slice(1), 16))
if (js_v.length !== py_v.length)
equal = false
else {
for (let i = 0; i < js_v.length; i++) {
delete (js_v[i] as any).id
delete (py_v[i] as any).id
if (!isEqual(js_v[i], py_v[i])) {
equal = false
break
}
}
}
if (equal)
continue
}
different.push(`${name}.${k}: bokehjs defaults to ${safe_stringify(js_v)} but python defaults to ${safe_stringify(py_v)}`)
}
} else {
python_missing.push(`${name}.${k}: bokehjs defaults to ${safe_stringify(js_v)} but python has no such property`)
}
}
for (const k in python_defaults) {
if (!(k in bokehjs_defaults)) {
const v = python_defaults[k]
bokehjs_missing.push(`${name}.${k}: python defaults to ${safe_stringify(v)} but bokehjs has no such property`)
}
}
function complain(failures: string[], message: string): void {
if (failures.length > 0) {
console.error(message)
for (const f of failures)
console.error(` ${f}`)
}
}
//.........这里部分代码省略.........
示例7: isObject
export function isField<T>(obj: Vectorized<T>): obj is Field {
return isObject(obj) && "field" in (obj as any)
}
示例8: _value_to_json
static _value_to_json(key: string, value: any, optional_parent_object: any): any {
if (isObject(value) && key === 'data')
return encode_column_data(value, optional_parent_object._shapes)
else
return HasProps._value_to_json(key, value, optional_parent_object)
}