From 67e796d12d980ceba4a736ce4fdd233db6e87729 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 30 Jun 2023 13:25:38 +0200 Subject: [PATCH] Add a HideTopicMatcher type guard. --- source/storage/hide-topics.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/storage/hide-topics.ts b/source/storage/hide-topics.ts index 23b9c70..267eb14 100644 --- a/source/storage/hide-topics.ts +++ b/source/storage/hide-topics.ts @@ -12,6 +12,14 @@ export enum HideTopicMatcher { UserLabelEquals = "user-label-equals", } +/** + * Type guard check to see if a string is a valid {@link HideTopicMatcher}. + * @param input The string to check. + */ +export function isHideTopicMatcher(input: string): input is HideTopicMatcher { + return Object.values(HideTopicMatcher).includes(input as HideTopicMatcher); +} + /** * The predicate for whether a topic should be hidden or not. */