MCPcopy Index your code
hub / github.com/CapSoftware/Cap / normalizeDevicePreference

Function normalizeDevicePreference

apps/chrome-extension/src/shared/storage.ts:547–574  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

545 : defaultSettings.capture.recordingMode;
546
547const normalizeDevicePreference = (value: unknown): DevicePreference | null => {
548 if (!value || typeof value !== "object") return null;
549 const candidate = value as Partial<DevicePreference>;
550 if (
551 typeof candidate.deviceId !== "string" ||
552 candidate.deviceId.trim().length === 0
553 ) {
554 return null;
555 }
556
557 return {
558 deviceId: candidate.deviceId,
559 label:
560 typeof candidate.label === "string" && candidate.label.trim().length > 0
561 ? candidate.label
562 : null,
563 groupId:
564 typeof candidate.groupId === "string" &&
565 candidate.groupId.trim().length > 0
566 ? candidate.groupId
567 : null,
568 updatedAt:
569 typeof candidate.updatedAt === "number" &&
570 Number.isFinite(candidate.updatedAt)
571 ? candidate.updatedAt
572 : 0,
573 };
574};
575
576const normalizeCapturePreferences = (value: unknown): CapturePreferences => {
577 const capture =

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected