Skip to content

Instantly share code, notes, and snippets.

@mirashif
Created July 28, 2024 10:10
Show Gist options
  • Save mirashif/b00313e8c446b0d583aa05f879a16d74 to your computer and use it in GitHub Desktop.
Save mirashif/b00313e8c446b0d583aa05f879a16d74 to your computer and use it in GitHub Desktop.
export default function isEmpty<T>(data: T): boolean {
if (Array.isArray(data)) return !data.length;
if (typeof data === "object" && data !== null)
return !Object.keys(data).length;
return !data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment