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


TypeScript types.isObject函數代碼示例

本文整理匯總了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)
   }
 }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:7,代碼來源:column_data_source.ts

示例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
}
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:7,代碼來源:column_data_source.ts

示例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)
      })
開發者ID:jsignell,項目名稱:bokeh,代碼行數:13,代碼來源:serialization.ts

示例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])
    }
  }
}
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:14,代碼來源:defaults.ts

示例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
}
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:19,代碼來源:defaults.ts

示例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}`)
    }
  }

//.........這裏部分代碼省略.........
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:101,代碼來源:defaults.ts

示例7: isObject

export function isField<T>(obj: Vectorized<T>): obj is Field {
  return isObject(obj) && "field" in (obj as any)
}
開發者ID:Zyell,項目名稱:bokeh,代碼行數:3,代碼來源:vectorization.ts

示例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)
 }
開發者ID:,項目名稱:,代碼行數:6,代碼來源:


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