From b908749d7cbc893c6a58eb2db9c74e423d78f805 Mon Sep 17 00:00:00 2001 From: Bauke Date: Fri, 11 Aug 2023 11:23:29 +0200 Subject: [PATCH] Move the Anonymize Usernames storage to its own file. --- source/storage/anonymize-usernames.ts | 23 +++++++++++++++++++++++ source/storage/exports.ts | 9 ++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 source/storage/anonymize-usernames.ts diff --git a/source/storage/anonymize-usernames.ts b/source/storage/anonymize-usernames.ts new file mode 100644 index 0000000..7653a78 --- /dev/null +++ b/source/storage/anonymize-usernames.ts @@ -0,0 +1,23 @@ +/** + * The different types of username replacements for the Anonymize Usernames + * feature. + */ +export enum ReplacementType { + Hashed = "hashed", + Numerical = "numerical", +} + +/** + * Type guard check to see if a string is a valid {@link ReplacementType}. + * @param input The string to check. + */ +export function isReplacementType(input: string): input is ReplacementType { + return Object.values(ReplacementType).includes(input as ReplacementType); +} + +/** + * The data stored for the Anonymize Usernames feature. + */ +export type AnonymizeUsernamesData = { + replacementType: ReplacementType; +}; diff --git a/source/storage/exports.ts b/source/storage/exports.ts index f29625a..131075c 100644 --- a/source/storage/exports.ts +++ b/source/storage/exports.ts @@ -1,23 +1,18 @@ import {createValue, type Value} from "@holllo/webextension-storage"; import browser from "webextension-polyfill"; +import {type AnonymizeUsernamesData} from "./anonymize-usernames.js"; import {Data, Feature, MiscellaneousFeature} from "./enums.js"; import {collectHideTopicsData} from "./hide-topics.js"; import {defaultKnownGroups} from "./known-groups.js"; import {collectUsernameColors} from "./username-color.js"; import {collectUserLabels} from "./user-label.js"; +export * from "./anonymize-usernames.js"; export * from "./enums.js"; export * from "./hide-topics.js"; export * from "./username-color.js"; export * from "./user-label.js"; -/** - * The data stored for the Anonymize Usernames feature. - */ -export type AnonymizeUsernamesData = { - replacementType: "numerical" | "hashed"; -}; - /** * The data stored for the Hide Votes feature. */