src/platforms/weex/framework.js
function normalize (v, instance) {
  const type = typof(v)

  switch (type) {
    case 'undefined':
    case 'null':
      return ''
    case 'regexp':
      return v.toString()
    case 'date':
      return v.toISOString()
    case 'number':
    case 'string':
    case 'boolean':
    case 'array':
    case 'object':
      if (v instanceof renderer.Element) {
        return v.ref
      }
      return v
    case 'function':
      instance.callbacks[++instance.callbackId] = v
      return instance.callbackId.toString()
    default:
      return JSON.stringify(v)
  }
}
function normalize (v, instance) {
  const type = typof(v)

  switch (type) {
    case 'undefined':
    case 'null':
      return ''
    case 'regexp':
      return v.toString()
    case 'date':
      return v.toISOString()
    case 'number':
    case 'string':
    case 'boolean':
    case 'array':
    case 'object':
      if (v instanceof renderer.Element) {
        return v.ref
      }
      return v
    case 'function':
      instance.callbacks[++instance.callbackId] = v
      return instance.callbackId.toString()
    default:
      return JSON.stringify(v)
  }
}
function normalize ( v , instance ) { const type = typof ( v ) switch ( type ) { case 'undefined' : case 'null' : return '' case 'regexp' : return v . toString ( ) case 'date' : return v . toISOString ( ) case 'number' : case 'string' : case 'boolean' : case 'array' : case 'object' : if ( v instanceof renderer . Element ) { return v . ref } return v case 'function' : instance . callbacks [ ++ instance . callbackId ] = v return instance . callbackId . toString ( ) default : return JSON . stringify ( v ) } }
Convert all type of values into "safe" format to send to native.
1. A `function` will be converted into callback id.
2. An `Element` object will be converted into `ref`.
The `instance` param is used to generate callback id and store
function if necessary.
@param  {any}    v
@param  {object} instance
@return {any}
Convert all type of values into safe format to send to native . 1 . A function will be converted into callback id . 2 . An Element object will be converted into ref . The instance param is used to generate callback id and store function if necessary .