From d1fe3a49e44f662a412ca14bd3e1e714aa658b6f Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Tue, 22 Dec 2020 15:17:59 -0800 Subject: [PATCH] Fixed Typescript defs --- src/devices/absolutemotor.ts | 6 +++--- src/devices/colordistancesensor.ts | 4 ++-- src/devices/duplotrainbasespeaker.ts | 2 +- src/devices/hubled.ts | 4 ++-- src/devices/light.ts | 2 +- src/devices/tachomotor.ts | 4 ++-- src/hubs/lpf2hub.ts | 2 +- src/hubs/wedo2smarthub.ts | 4 ++-- src/nobleabstraction.ts | 4 ++-- src/poweredup-browser.ts | 2 +- src/webbleabstraction.ts | 6 +++--- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/devices/absolutemotor.ts b/src/devices/absolutemotor.ts index 8ab4770..41178c4 100644 --- a/src/devices/absolutemotor.ts +++ b/src/devices/absolutemotor.ts @@ -50,7 +50,7 @@ export class AbsoluteMotor extends TachoMotor { throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub"); } this.cancelEventTimer(); - return new Promise((resolve) => { + return new Promise((resolve) => { this._busy = true; if (speed === undefined || speed === null) { speed = 100; @@ -81,7 +81,7 @@ export class AbsoluteMotor extends TachoMotor { * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished). */ public gotoRealZero (speed: number = 100) { - return new Promise((resolve) => { + return new Promise((resolve) => { const oldMode = this.mode; let calibrated = false; this.on("absolute", async ({ angle }) => { @@ -110,7 +110,7 @@ export class AbsoluteMotor extends TachoMotor { * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished). */ public resetZero () { - return new Promise((resolve) => { + return new Promise((resolve) => { const data = Buffer.from([0x81, this.portId, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]); this.send(data); return resolve(); diff --git a/src/devices/colordistancesensor.ts b/src/devices/colordistancesensor.ts index 67868cc..dbe6a8c 100644 --- a/src/devices/colordistancesensor.ts +++ b/src/devices/colordistancesensor.ts @@ -178,7 +178,7 @@ export class ColorDistanceSensor extends Device { * @returns {Promise} Resolved upon successful issuance of the command. */ public setColor (color: number | boolean) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (color === false) { color = 0; } @@ -186,7 +186,7 @@ export class ColorDistanceSensor extends Device { throw new Error("Setting LED color is not available on the WeDo 2.0 Smart Hub"); } else { this.subscribe(Mode.LED); - this.writeDirect(0x05, Buffer.from([color])); + this.writeDirect(0x05, Buffer.from([color as number])); } return resolve(); }); diff --git a/src/devices/duplotrainbasespeaker.ts b/src/devices/duplotrainbasespeaker.ts index 2187a6c..efb3ce9 100644 --- a/src/devices/duplotrainbasespeaker.ts +++ b/src/devices/duplotrainbasespeaker.ts @@ -21,7 +21,7 @@ export class DuploTrainBaseSpeaker extends Device { * @returns {Promise} Resolved upon successful issuance of the command. */ public playSound (sound: Consts.DuploTrainBaseSound) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this.subscribe(Mode.SOUND); this.writeDirect(0x01, Buffer.from([sound])); return resolve(); diff --git a/src/devices/hubled.ts b/src/devices/hubled.ts index a7bf9ad..c52cd0a 100644 --- a/src/devices/hubled.ts +++ b/src/devices/hubled.ts @@ -23,7 +23,7 @@ export class HubLED extends Device { * @returns {Promise} Resolved upon successful issuance of the command. */ public setColor (color: number | boolean) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (typeof color === "boolean") { color = 0; } @@ -48,7 +48,7 @@ export class HubLED extends Device { * @returns {Promise} Resolved upon successful issuance of the command. */ public setRGB (red: number, green: number, blue: number) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (this.isWeDo2SmartHub) { this.send(Buffer.from([0x06, 0x17, 0x01, 0x02]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE); this.send(Buffer.from([0x06, 0x04, 0x03, red, green, blue]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE); diff --git a/src/devices/light.ts b/src/devices/light.ts index 7bb58d8..c079085 100644 --- a/src/devices/light.ts +++ b/src/devices/light.ts @@ -27,7 +27,7 @@ export class Light extends Device { if (interrupt) { this.cancelEventTimer(); } - return new Promise((resolve) => { + return new Promise((resolve) => { this.writeDirect(0x00, Buffer.from([brightness])); return resolve(); }); diff --git a/src/devices/tachomotor.ts b/src/devices/tachomotor.ts index 6650d06..d54ca79 100644 --- a/src/devices/tachomotor.ts +++ b/src/devices/tachomotor.ts @@ -103,7 +103,7 @@ export class TachoMotor extends BasicMotor { throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub"); } this.cancelEventTimer(); - return new Promise((resolve) => { + return new Promise((resolve) => { this._busy = true; if (speed === undefined || speed === null) { speed = 100; @@ -145,7 +145,7 @@ export class TachoMotor extends BasicMotor { throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub"); } this.cancelEventTimer(); - return new Promise((resolve) => { + return new Promise((resolve) => { this._busy = true; if (speed === undefined || speed === null) { speed = 100; diff --git a/src/hubs/lpf2hub.ts b/src/hubs/lpf2hub.ts index 6b7245c..f003467 100644 --- a/src/hubs/lpf2hub.ts +++ b/src/hubs/lpf2hub.ts @@ -174,7 +174,7 @@ export class LPF2Hub extends BaseHub { private _requestHubPropertyValue (property: number) { - return new Promise((resolve) => { + return new Promise((resolve) => { this._propertyRequestCallbacks[property] = (message) => { this._parseHubPropertyResponse(message); return resolve(); diff --git a/src/hubs/wedo2smarthub.ts b/src/hubs/wedo2smarthub.ts index 9c90a14..d7ffa0c 100644 --- a/src/hubs/wedo2smarthub.ts +++ b/src/hubs/wedo2smarthub.ts @@ -41,7 +41,7 @@ export class WeDo2SmartHub extends BaseHub { public connect () { - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve) => { debug("Connecting to WeDo 2.0 Smart Hub"); await super.connect(); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB); @@ -113,7 +113,7 @@ export class WeDo2SmartHub extends BaseHub { if (name.length > 14) { throw new Error("Name must be 14 characters or less"); } - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const data = Buffer.from(name, "ascii"); // Send this twice, as sometimes the first time doesn't take this.send(data, Consts.BLECharacteristic.WEDO2_NAME_ID); diff --git a/src/nobleabstraction.ts b/src/nobleabstraction.ts index 1d56742..1791e29 100644 --- a/src/nobleabstraction.ts +++ b/src/nobleabstraction.ts @@ -92,9 +92,9 @@ export class NobleDevice extends EventEmitter implements IBLEAbstraction { return discoverReject(err); } debug("Service/characteristic discovery started"); - const servicePromises: Promise[] = []; + const servicePromises: Promise[] = []; services.forEach((service) => { - servicePromises.push(new Promise((resolve, reject) => { + servicePromises.push(new Promise((resolve) => { service.discoverCharacteristics([], (err, characteristics) => { characteristics.forEach((characteristic) => { this._characteristics[characteristic.uuid] = characteristic; diff --git a/src/poweredup-browser.ts b/src/poweredup-browser.ts index 779f7ac..e21864a 100644 --- a/src/poweredup-browser.ts +++ b/src/poweredup-browser.ts @@ -128,7 +128,7 @@ export class PoweredUP extends EventEmitter { private _determineLPF2HubType (device: IBLEAbstraction): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { let buf: Buffer = Buffer.alloc(0); device.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, (data: Buffer) => { buf = Buffer.concat([buf, data]); diff --git a/src/webbleabstraction.ts b/src/webbleabstraction.ts index 8244210..5afe811 100644 --- a/src/webbleabstraction.ts +++ b/src/webbleabstraction.ts @@ -14,7 +14,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction { private _listeners: {[uuid: string]: any} = {}; private _characteristics: {[uuid: string]: any} = {}; - private _queue: Promise = Promise.resolve(); + private _queue: Promise = Promise.resolve(); private _mailbox: Buffer[] = []; private _connected: boolean = false; @@ -58,7 +58,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction { public connect () { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this._connected = true; return resolve(); }); @@ -66,7 +66,7 @@ export class WebBLEDevice extends EventEmitter implements IBLEAbstraction { public disconnect () { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this._webBLEServer.device.gatt.disconnect(); return resolve(); });