isEmpty.ts 461 Bytes
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
export const isEmpty = function (data: any) {
  if (data === '' || data === null || data === undefined) {
    return true;
  } else {
    const typeofs = Object.prototype.toString.call(data);
    if (typeofs === '[object Array]') {
      if (data.length > 0) {
        return false;
      } else {
        return true;
      }
    } else {
      if (Object.keys(data).length > 0) {
        return false;
      } else {
        return true;
      }
    }
  }
};