Skip to content

Commit 2ede713

Browse files
committed
refactor: extract storage record utils
1 parent cc40cc3 commit 2ede713

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/storage.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
collectNamedBackups,
2828
type NamedBackupSummary,
2929
} from "./storage/named-backups.js";
30+
import { clampIndex, isRecord } from "./storage/record-utils.js";
3031
import {
3132
buildRestoreAssessment,
3233
collectBackupMetadata,
@@ -958,15 +959,6 @@ export function deduplicateAccountsByEmail<
958959
return deduplicateAccountsByIdentity(accounts);
959960
}
960961

961-
function isRecord(value: unknown): value is Record<string, unknown> {
962-
return !!value && typeof value === "object" && !Array.isArray(value);
963-
}
964-
965-
function clampIndex(index: number, length: number): number {
966-
if (length <= 0) return 0;
967-
return Math.max(0, Math.min(index, length - 1));
968-
}
969-
970962
function extractActiveAccountRef(
971963
accounts: unknown[],
972964
activeIndex: number,

lib/storage/record-utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function isRecord(value: unknown): value is Record<string, unknown> {
2+
return !!value && typeof value === "object" && !Array.isArray(value);
3+
}
4+
5+
export function clampIndex(index: number, length: number): number {
6+
if (length <= 0) return 0;
7+
return Math.max(0, Math.min(index, length - 1));
8+
}

0 commit comments

Comments
 (0)