Skip to main content

extractConstraintsWithKeys

function extractConstraintsWithKeys<T>(keys): (constraints) => Pick<Constraints, T>;

Extract the constraints with provided keys

Type Parameters

Type Parameter
T extends | "deviceId" | "groupId" | "device" | "videoSegmentation" | "videoSegmentationModel" | "denoise" | "vad" | "asd" | "mixWithAdditionalMedia" | "backgroundImageUrl" | "resizeMode" | "pan" | "tilt" | "zoom" | "contentHint" | "facingMode" | "echoCancellation" | "autoGainControl" | "noiseSuppression" | ConstrainNumberKeys

Parameters

ParameterTypeDescription
keysreadonly T[]The keys to be used for the extraction

Returns

an object with the provided key and the value-param tuple

(constraints): Pick<Constraints, T>;

Parameters

ParameterType
constraints| undefined | InputDeviceConstraint

Returns

Pick<Constraints, T>

Example

const device = {deviceId: 'xxxx', label: 'abc', kind: 'audioinput'};
const constraints = { device, noiseSuppression: true };
const extract = extractConstraintsWithKeys(['device', 'noiseSuppression']);
const {
device: [devices, deviceParam],
noiseSuppression: [noiseSuppression, noiseSuppressionParam],
} = extract(constraints);
expect(devices).toEqual([device]);
expect(deviceParam).toEqual('ideal');
expect(noiseSuppression).toEqual(true);
expect(noiseSuppressionParam).toEqual('ideal');