Skip to content

Commit

Permalink
chore: use ternary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
evujici committed Sep 20, 2024
1 parent ae1e499 commit 244749c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/device/device-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,9 @@ export async function createDisplayStreamWithAudio<
*/
export async function getDevices(deviceKind?: media.DeviceKind): Promise<MediaDeviceInfo[]> {
let devices: MediaDeviceInfo[];
const deviceKinds: media.DeviceKind[] = [];

// If deviceKind is provided, add it to the array. Otherwise, add both audio and video input kinds.
if (deviceKind !== undefined) {
deviceKinds.push(deviceKind);
} else {
deviceKinds.push(media.DeviceKind.AudioInput, media.DeviceKind.VideoInput);
}
const deviceKinds = deviceKind
? [deviceKind]
: [media.DeviceKind.AudioInput, media.DeviceKind.VideoInput];

try {
devices = await media.ensureDevicePermissions(deviceKinds, media.enumerateDevices);
Expand Down

0 comments on commit 244749c

Please sign in to comment.