refactor: dedupe msteams record helper

This commit is contained in:
Peter Steinberger
2026-04-06 22:50:51 +01:00
parent 92e3299793
commit a8ac0b7976
2 changed files with 3 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
import { isRecord } from "./attachments/shared.js";
export function formatUnknownError(err: unknown): string {
if (err instanceof Error) {
return err.message;
@@ -27,10 +29,6 @@ export function formatUnknownError(err: unknown): string {
}
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function extractStatusCode(err: unknown): number | null {
if (!isRecord(err)) {
return null;

View File

@@ -1,4 +1,5 @@
import crypto from "node:crypto";
import { isRecord } from "./attachments/shared.js";
import { resolveMSTeamsStorePath } from "./storage.js";
import { readJsonFile, withFileLock, writeJsonFile } from "./store-fs.js";
@@ -46,9 +47,6 @@ type PollStoreData = {
const STORE_FILENAME = "msteams-polls.json";
const MAX_POLLS = 1000;
const POLL_TTL_MS = 30 * 24 * 60 * 60 * 1000;
function isRecord(value: unknown): value is Record<string, unknown> {
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
}
function normalizeChoiceValue(value: unknown): string | null {
if (typeof value === "string") {