Files
MikrotikManager/lib/wg-export-peer.ts
T

5 lines
318 B
TypeScript

/** An explicit missing selection must never fall back to another peer. */
export function selectWgExportPeer<T extends { id?: string; rosId?: string }>(peers: readonly T[], peerId?: string | null): T | undefined {
return peerId == null ? peers[0] : peers.find(peer => peer.id === peerId || peer.rosId === peerId)
}