types.ts 754 B

123456789101112131415161718192021222324252627282930
  1. import { isArray, isObject } from '@vue/shared'
  2. import { isNil } from 'lodash-unified'
  3. export {
  4. isArray,
  5. isFunction,
  6. isObject,
  7. isString,
  8. isDate,
  9. isPromise,
  10. isSymbol,
  11. } from '@vue/shared'
  12. export { isBoolean, isNumber } from '@vueuse/core'
  13. export { isVNode } from 'vue'
  14. export const isUndefined = (val: any): val is undefined => val === undefined
  15. export const isEmpty = (val: unknown) =>
  16. (!val && val !== 0) ||
  17. (isArray(val) && val.length === 0) ||
  18. (isObject(val) && !Object.keys(val).length)
  19. export const isElement = (e: unknown): e is Element => {
  20. if (typeof Element === 'undefined') return false
  21. return e instanceof Element
  22. }
  23. export const isPropAbsent = (prop: unknown): prop is null | undefined => {
  24. return isNil(prop)
  25. }