Update @types/web-bluetooth

Now includes writeValueWithResponse and writeValueWithoutResponse
This commit is contained in:
David Lechner
2020-07-15 13:17:40 -05:00
committed by David Lechner
parent 70d98511c2
commit 5c3727b3ce
3 changed files with 7 additions and 10 deletions
+2 -5
View File
@@ -7,8 +7,6 @@
*/
export interface PolyfillBluetoothRemoteGATTCharacteristic
extends BluetoothRemoteGATTCharacteristic {
writeValueWithResponse?(value: BufferSource): Promise<void>;
writeValueWithoutResponse?(value: BufferSource): Promise<void>;
/**
* Calls writeValueWithResponse() if available otherwise falls back to writeValue()
* @param value data to send
@@ -30,9 +28,8 @@ export function polyfillBluetoothRemoteGATTCharacteristic(
char: BluetoothRemoteGATTCharacteristic,
): PolyfillBluetoothRemoteGATTCharacteristic {
const polyfill = (char as unknown) as PolyfillBluetoothRemoteGATTCharacteristic;
polyfill.xWriteValueWithResponse =
polyfill.writeValueWithResponse || char.writeValue;
polyfill.xWriteValueWithResponse = char.writeValueWithResponse || char.writeValue;
polyfill.xWriteValueWithoutResponse =
polyfill.writeValueWithoutResponse || char.writeValue;
char.writeValueWithoutResponse || char.writeValue;
return polyfill;
}