From 9ab009b5b4ab08d4fbe7225399f7e803cd363d24 Mon Sep 17 00:00:00 2001 From: Nathan Kunicki Date: Thu, 21 Jun 2018 10:49:26 +0100 Subject: [PATCH] Added Promise return types to jsdoc --- README.md | 30 ++++++++++++++++++------------ boosthub.ts | 3 +++ wedo2hub.ts | 3 +++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2407ac7..fb0769c 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,9 @@ Emits when a LPF2 Hub device is found. **Extends**: [Hub](#Hub) * [BoostHub](#BoostHub) ⇐ [Hub](#Hub) - * [.setLEDColor(color)](#BoostHub+setLEDColor) - * [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed) - * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) + * [.setLEDColor(color)](#BoostHub+setLEDColor) ⇒ Promise + * [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed) ⇒ Promise + * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) ⇒ Promise * [.connect([callback])](#Hub+connect) * [.subscribe(port, [mode])](#Hub+subscribe) * [.unsubscribe(port)](#Hub+unsubscribe) @@ -59,10 +59,11 @@ Emits when a LPF2 Hub device is found. -### boostHub.setLEDColor(color) +### boostHub.setLEDColor(color) ⇒ Promise Set the color of the LED on the Hub via a color value. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - - Resolved upon successful completion of command. | Param | Type | Description | | --- | --- | --- | @@ -70,10 +71,11 @@ Set the color of the LED on the Hub via a color value. -### boostHub.setMotorSpeed(port, speed, [time]) +### boostHub.setMotorSpeed(port, speed, [time]) ⇒ Promise Set the motor speed on a given port. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - - Resolved upon successful completion of command. If time is specified, this is once the motor is finished. | Param | Type | Description | | --- | --- | --- | @@ -83,10 +85,11 @@ Set the motor speed on a given port. -### boostHub.setMotorAngle(port, angle, [speed]) +### boostHub.setMotorAngle(port, angle, [speed]) ⇒ Promise Rotate a motor by a given angle. **Kind**: instance method of [BoostHub](#BoostHub) +**Returns**: Promise - - Resolved upon successful completion of command (ie. once the motor is finished). | Param | Type | Default | Description | | --- | --- | --- | --- | @@ -196,9 +199,9 @@ Emits when a rotation sensor is activated. **Extends**: [Hub](#Hub) * [WeDo2Hub](#WeDo2Hub) ⇐ [Hub](#Hub) - * [.setLEDColor(color)](#WeDo2Hub+setLEDColor) - * [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB) - * [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed) + * [.setLEDColor(color)](#WeDo2Hub+setLEDColor) ⇒ Promise + * [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB) ⇒ Promise + * [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed) ⇒ Promise * [.connect([callback])](#Hub+connect) * [.subscribe(port, [mode])](#Hub+subscribe) * [.unsubscribe(port)](#Hub+unsubscribe) @@ -210,10 +213,11 @@ Emits when a rotation sensor is activated. -### weDo2Hub.setLEDColor(color) +### weDo2Hub.setLEDColor(color) ⇒ Promise Set the color of the LED on the Hub via a color value. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - - Resolved upon successful completion of command. | Param | Type | Description | | --- | --- | --- | @@ -221,10 +225,11 @@ Set the color of the LED on the Hub via a color value. -### weDo2Hub.setLEDRGB(red, green, blue) +### weDo2Hub.setLEDRGB(red, green, blue) ⇒ Promise Set the color of the LED on the Hub via RGB values. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - - Resolved upon successful completion of command. | Param | Type | | --- | --- | @@ -234,10 +239,11 @@ Set the color of the LED on the Hub via RGB values. -### weDo2Hub.setMotorSpeed(port, speed) +### weDo2Hub.setMotorSpeed(port, speed) ⇒ Promise Set the motor speed on a given port. **Kind**: instance method of [WeDo2Hub](#WeDo2Hub) +**Returns**: Promise - - Resolved upon successful completion of command. | Param | Type | Description | | --- | --- | --- | diff --git a/boosthub.ts b/boosthub.ts index 4fdebc7..cebf104 100644 --- a/boosthub.ts +++ b/boosthub.ts @@ -58,6 +58,7 @@ export class BoostHub extends Hub { * Set the color of the LED on the Hub via a color value. * @method BoostHub#setLEDColor * @param {number} color - A number representing one of the LED color consts. + * @returns {Promise} - Resolved upon successful completion of command. */ public setLEDColor (color: number | boolean) { return new Promise((resolve, reject) => { @@ -93,6 +94,7 @@ export class BoostHub extends Hub { * @param {string} port * @param {number} speed - For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. * @param {number} [time] - How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely. + * @returns {Promise} - Resolved upon successful completion of command. If time is specified, this is once the motor is finished. */ public setMotorSpeed (port: string, speed: number, time: number) { return new Promise((resolve, reject) => { @@ -123,6 +125,7 @@ export class BoostHub extends Hub { * @param {string} port * @param {number} angle - How much the motor should be rotated (in degrees). * @param {number} [speed=100] - How fast the motor should be rotated. + * @returns {Promise} - Resolved upon successful completion of command (ie. once the motor is finished). */ public setMotorAngle (port: string, angle: number, speed: number = 100) { return new Promise((resolve, reject) => { diff --git a/wedo2hub.ts b/wedo2hub.ts index 27f59a5..e3ec470 100644 --- a/wedo2hub.ts +++ b/wedo2hub.ts @@ -54,6 +54,7 @@ export class WeDo2Hub extends Hub { * Set the color of the LED on the Hub via a color value. * @method WeDo2Hub#setLEDColor * @param {number} color - A number representing one of the LED color consts. + * @returns {Promise} - Resolved upon successful completion of command. */ public setLEDColor (color: number | boolean) { return new Promise((resolve, reject) => { @@ -79,6 +80,7 @@ export class WeDo2Hub extends Hub { * @param {number} red * @param {number} green * @param {number} blue + * @returns {Promise} - Resolved upon successful completion of command. */ public setLEDRGB (red: number, green: number, blue: number) { return new Promise((resolve, reject) => { @@ -100,6 +102,7 @@ export class WeDo2Hub extends Hub { * @method WeDo2Hub#setMotorSpeed * @param {string} port * @param {number} speed - For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. + * @returns {Promise} - Resolved upon successful completion of command. */ public setMotorSpeed (port: string, speed: number) { return new Promise((resolve, reject) => {