From 244749c2559c053fa9850c73398757dd79503ee7 Mon Sep 17 00:00:00 2001 From: evujici Date: Fri, 20 Sep 2024 09:12:04 +0200 Subject: [PATCH] chore: use ternary operator --- src/device/device-management.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/device/device-management.ts b/src/device/device-management.ts index b606d4d..e700310 100644 --- a/src/device/device-management.ts +++ b/src/device/device-management.ts @@ -190,14 +190,9 @@ export async function createDisplayStreamWithAudio< */ export async function getDevices(deviceKind?: media.DeviceKind): Promise { 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);