Skip to content

Commit

Permalink
Added more instances type-guards
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Oct 28, 2022
1 parent a57b300 commit 3a9fb7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-numbers-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finsweet/ts-utils': patch
---

Added more instances type-guards
15 changes: 15 additions & 0 deletions src/type-guards/instances.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const isFile = (target: unknown): target is File => target instanceof File;

export const isNode = (target: unknown): target is Node => target instanceof Node;

export const isElement = (target: unknown): target is Element => target instanceof Element;
Expand All @@ -11,3 +13,16 @@ export const isHTMLSelectElement = (target: unknown): target is HTMLSelectElemen

export const isHTMLTextAreaElement = (target: unknown): target is HTMLTextAreaElement =>
target instanceof HTMLTextAreaElement;

export const isHTMLVideoElement = (target: unknown): target is HTMLVideoElement => target instanceof HTMLVideoElement;

export const isHTMLAnchorElement = (target: unknown): target is HTMLAnchorElement =>
target instanceof HTMLAnchorElement;

export const isHTMLImageElement = (target: unknown): target is HTMLImageElement => target instanceof HTMLImageElement;

export const isHTMLOptionElement = (target: unknown): target is HTMLOptionElement =>
target instanceof HTMLOptionElement;

export const isHTMLButtonElement = (target: unknown): target is HTMLButtonElement =>
target instanceof HTMLButtonElement;

0 comments on commit 3a9fb7e

Please sign in to comment.