text: // 由一个组件，向上找到最近的指定组件
  function findComponentUpward (context, componentName) {
    let parent = context.$parent
    let name = parent.$options.name
  
    while (parent && (!name || [componentName].indexOf(name) < 0)) {
      parent = parent.$parent
      if (parent) name = parent.$options.name
    }
    return parent
  }
  
  // 由一个组件，向下找到最近的指定组件
  function findComponentDownward (context, componentName) {
    const childrens = context.$children
    let children = null
  
    if (childrens.length) {
      for (const child of childrens) {
        const name = child.$options.name
  
        if (name === componentName) {
          children = child
          break
        } else {
          children = findComponentDownward(child, componentName)
          if (children) break
        }
      }
    }
    return children
  }
  
  // 由一个组件，向下找到所有指定的组件
  function findComponentsDownward (context, componentName) {
    return context.$children.reduce((components, child) => {
      if (child.$options.name === componentName) components.push(child)
      const foundChilds = findComponentsDownward(child, componentName)
      return components.concat(foundChilds)
    }, [])
  }
  
  function typeOf (obj) {
    return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase()
  }
  
  function deepCopy (data) {
    const t = typeOf(data)
    let o
  
    if (t === 'array') {
      o = []
    } else if (t === 'object') {
      o = {}
    } else {
      return data
    }
  
    if (t === 'array') {
      for (let i = 0; i < data.length; i++) {
        o.push(deepCopy(data[i]))
      }
    } else if (t === 'object') {
      for (let i in data) {
        o[i] = deepCopy(data[i])
      }
    }
    return o
  }
  
  export { findComponentUpward }
  export { findComponentDownward }
  export { findComponentsDownward }
  export { deepCopy }
  