Comparing version 3.0.0-alpha.3 to 3.0.0-alpha.4
@@ -58,3 +58,5 @@ /*! | ||
sensorRead(sensorIndex: number, sensorType: Messages.SensorType): Promise<number[]>; | ||
get hasBattery(): boolean; | ||
battery(): Promise<number>; | ||
get hasRssi(): boolean; | ||
rssi(): Promise<number>; | ||
@@ -61,0 +63,0 @@ rawRead(endpoint: string, expectedLength: number, timeout: number): Promise<Uint8Array>; |
@@ -228,9 +228,14 @@ /*! | ||
} | ||
get hasBattery() { | ||
var _a; | ||
const batteryAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.Battery); | ||
return batteryAttrs !== undefined && batteryAttrs.length > 0; | ||
} | ||
battery() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const batteryAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.Battery); | ||
if (!batteryAttrs || batteryAttrs.length === 0) { | ||
if (!this.hasBattery) { | ||
throw new Exceptions_1.ButtplugDeviceException(`Device ${this.name} has no Battery capabilities`); | ||
} | ||
const batteryAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.Battery); | ||
// Find the battery sensor, we'll need its index. | ||
@@ -241,9 +246,14 @@ const result = yield this.sensorRead(batteryAttrs[0].Index, Messages.SensorType.Battery); | ||
} | ||
get hasRssi() { | ||
var _a; | ||
const rssiAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.RSSI); | ||
return rssiAttrs !== undefined && rssiAttrs.length === 0; | ||
} | ||
rssi() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rssiAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.RSSI); | ||
if (!rssiAttrs || rssiAttrs.length === 0) { | ||
if (!this.hasRssi) { | ||
throw new Exceptions_1.ButtplugDeviceException(`Device ${this.name} has no RSSI capabilities`); | ||
} | ||
const rssiAttrs = (_a = this.messageAttributes.SensorReadCmd) === null || _a === void 0 ? void 0 : _a.filter((x) => x.SensorType === Messages.SensorType.RSSI); | ||
// Find the battery sensor, we'll need its index. | ||
@@ -250,0 +260,0 @@ const result = yield this.sensorRead(rssiAttrs[0].Index, Messages.SensorType.RSSI); |
{ | ||
"name": "buttplug", | ||
"version": "3.0.0-alpha.3", | ||
"version": "3.0.0-alpha.4", | ||
"description": "Buttplug Client Implementation for Typescript/Javascript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/buttplugio/buttplug-js/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1403314
10957