types.ts 751 B

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