<commit_before>import velocity from 'velocity-animate'
import isPlainObject from 'lodash.isplainobject'
import _KeyCode from './KeyCode'
import _guid from './guid'
import _slotMixin from './slotMixin'

const toString = Object.prototype.toString

function animate (node, show, transitionName, done) {
  let ok

  const complete = () => {
    if (!ok) {
      ok = true
      done()
    }
  }

  node.style.display = show ? 'block' : 'none'

  velocity(node, transitionName, {
    duration: 240,
    complete: complete,
    easing: 'easeInOutQuad'
  })

  return {
    stop () {
      velocity(node, 'finish')
      complete()
    }
  }
}

export const slotMixin = _slotMixin
export const guid = _guid
export const KeyCode = _KeyCode
export const openAnimation = {
  enter (node, done) {
    return animate(node, false, 'slideDown', done)
  },

  leave (node, done) {
    return animate(node, true, 'slideUp', done)
  },

  appear (node, done) {
    return animate(node, false, 'slideDown', done)
  }
}

// 返回vue匹配的props的对象
export function defaultProps (props) {
  for (const i in props) {
    if (props.hasOwnProperty(i)) {
      let defaultValue = props[i]

      if (defaultValue.name && window[defaultValue.name] === defaultValue) {
        props[i] = {
          type: defaultValue,
          default: null
        }

        continue
      }

      if (isPlainObject(defaultValue)) continue

      let type = toString.call(defaultValue).replace('[object ', '').replace(']', '')

      props[i] = {
        type: window[type],
        default: defaultValue
      }
    }
  }

  return props
}

export function oneOfType (validList, defaultValue) {
  let validaObj = {}

  validaObj.default = defaultValue
  validaObj.validator = function (value) {
    for (let j = 0; j < validList.length; j++) {
      const validName = validList[j].name
      if (toString.call(value).indexOf(validName) > -1) {
        return true
      }
    }
    return false
  }

  return validaObj<commit_msg>oneOfType 支持null的情况<commit_after>import velocity from 'velocity-animate'
import isPlainObject from 'lodash.isplainobject'
import _KeyCode from './KeyCode'
import _guid from './guid'
import _slotMixin from './slotMixin'

const toString = Object.prototype.toString

function animate (node, show, transitionName, done) {
  let ok

  const complete = () => {
    if (!ok) {
      ok = true
      done()
    }
  }

  node.style.display = show ? 'block' : 'none'

  velocity(node, transitionName, {
    duration: 240,
    complete: complete,
    easing: 'easeInOutQuad'
  })

  return {
    stop () {
      velocity(node, 'finish')
      complete()
    }
  }
}

export const slotMixin = _slotMixin
export const guid = _guid
export const KeyCode = _KeyCode
export const openAnimation = {
  enter (node, done) {
    return animate(node, false, 'slideDown', done)
  },

  leave (node, done) {
    return animate(node, true, 'slideUp', done)
  },

  appear (node, done) {
    return animate(node, false, 'slideDown', done)
  }
}

// 返回vue匹配的props的对象
export function defaultProps (props) {
  for (const i in props) {
    if (props.hasOwnProperty(i)) {
      let defaultValue = props[i]

      if (defaultValue.name && window[defaultValue.name] === defaultValue) {
        props[i] = {
          type: defaultValue,
          default: null
        }

        continue
      }

      if (isPlainObject(defaultValue)) continue

      let type = toString.call(defaultValue).replace('[object ', '').replace(']', '')

      props[i] = {
        type: window[type],
        default: defaultValue
      }
    }
  }

  return props
}

export function oneOfType (validList, defaultValue) {
  let validaObj = {}

  validaObj.default = defaultValue
  validaObj.validator = function (value) {
    for (let j = 0; j < validList.length; j++) {
      const currentValid = validList[j]
      let validName
      if (typeof currentValid === 'string') {
        validName = currentValid
      } else {
        validName = currentValid.name
      }
      if (toString.call(value).indexOf(validName) > -1) {
        return true
      }
    }
    return false
  }

  return validaObj
{'fraction_non_alphanumeric': 0.12113152804642166, 'fraction_numerical': 0.0024177949709864605, 'mean_word_length': 2.6675531914893615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1494260', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1306, 'n_words': 339}