r37r0m0d3l/consono

View on GitHub
src/utils/objectType.js

Summary

Maintainability
A
0 mins
Test Coverage
import prototypeName from "./prototypeName.js";

export default function objectType(value) {
  const type = prototypeName(value).toLowerCase().split("[object ").pop().split("]").shift();
  if (["global", "window"].includes(type)) {
    return "object";
  }
  if (type.includes("error")) {
    return "error";
  }
  return type;
}