utils.ts 698 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 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
export function isObject(data: any) {
  const typeofs = Object.prototype.toString.call(data);
  if (typeofs === '[object Object]') {
    return true;
  } else {
    return false;
  }
}

export function isArray(data: any) {
  const typeofs = Object.prototype.toString.call(data);
  if (typeofs === '[object Array]') {
    return true;
  } else {
    return false;
  }
}

export function isLastArr(index: any, data: any) {
  const len = data.length;
  if (index === len - 1) {
    return true;
  } else {
    return false;
  }
}

export function isLastObj(index: any, data: any) {
  const len = Object.keys(data).length;
  if (index === len - 1) {
    return true;
  } else {
    return false;
  }
}