Added Promise return types to jsdoc

This commit is contained in:
Nathan Kunicki 2018-06-21 10:51:39 +01:00
parent 9ab009b5b4
commit 0f37d394b4
3 changed files with 25 additions and 25 deletions

View File

@ -63,7 +63,7 @@ Emits when a LPF2 Hub device is found.
Set the color of the LED on the Hub via a color value. Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub) **Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command. **Returns**: <code>Promise</code> - Resolved upon successful completion of command.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -75,7 +75,7 @@ Set the color of the LED on the Hub via a color value.
Set the motor speed on a given port. Set the motor speed on a given port.
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub) **Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command. If time is specified, this is once the motor is finished. **Returns**: <code>Promise</code> - Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -89,7 +89,7 @@ Set the motor speed on a given port.
Rotate a motor by a given angle. Rotate a motor by a given angle.
**Kind**: instance method of [<code>BoostHub</code>](#BoostHub) **Kind**: instance method of [<code>BoostHub</code>](#BoostHub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command (ie. once the motor is finished). **Returns**: <code>Promise</code> - Resolved upon successful completion of command (ie. once the motor is finished).
| Param | Type | Default | Description | | Param | Type | Default | Description |
| --- | --- | --- | --- | | --- | --- | --- | --- |
@ -217,7 +217,7 @@ Emits when a rotation sensor is activated.
Set the color of the LED on the Hub via a color value. Set the color of the LED on the Hub via a color value.
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub) **Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command. **Returns**: <code>Promise</code> - Resolved upon successful completion of command.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -229,7 +229,7 @@ Set the color of the LED on the Hub via a color value.
Set the color of the LED on the Hub via RGB values. Set the color of the LED on the Hub via RGB values.
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub) **Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command. **Returns**: <code>Promise</code> - Resolved upon successful completion of command.
| Param | Type | | Param | Type |
| --- | --- | | --- | --- |
@ -243,7 +243,7 @@ Set the color of the LED on the Hub via RGB values.
Set the motor speed on a given port. Set the motor speed on a given port.
**Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub) **Kind**: instance method of [<code>WeDo2Hub</code>](#WeDo2Hub)
**Returns**: <code>Promise</code> - - Resolved upon successful completion of command. **Returns**: <code>Promise</code> - Resolved upon successful completion of command.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |

View File

@ -57,8 +57,8 @@ export class BoostHub extends Hub {
/** /**
* Set the color of the LED on the Hub via a color value. * Set the color of the LED on the Hub via a color value.
* @method BoostHub#setLEDColor * @method BoostHub#setLEDColor
* @param {number} color - A number representing one of the LED color consts. * @param {number} color A number representing one of the LED color consts.
* @returns {Promise} - Resolved upon successful completion of command. * @returns {Promise} Resolved upon successful completion of command.
*/ */
public setLEDColor (color: number | boolean) { public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -92,9 +92,9 @@ export class BoostHub extends Hub {
* Set the motor speed on a given port. * Set the motor speed on a given port.
* @method BoostHub#setMotorSpeed * @method BoostHub#setMotorSpeed
* @param {string} port * @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} 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. * @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. * @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) { public setMotorSpeed (port: string, speed: number, time: number) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -123,9 +123,9 @@ export class BoostHub extends Hub {
* Rotate a motor by a given angle. * Rotate a motor by a given angle.
* @method BoostHub#setMotorAngle * @method BoostHub#setMotorAngle
* @param {string} port * @param {string} port
* @param {number} angle - How much the motor should be rotated (in degrees). * @param {number} angle How much the motor should be rotated (in degrees).
* @param {number} [speed=100] - How fast the motor should be rotated. * @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). * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/ */
public setMotorAngle (port: string, angle: number, speed: number = 100) { public setMotorAngle (port: string, angle: number, speed: number = 100) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -220,7 +220,7 @@ export class BoostHub extends Hub {
/** /**
* Emits when a button is pressed. * Emits when a button is pressed.
* @event BoostHub#button * @event BoostHub#button
* @param {number} state - A number representing one of the button state consts. * @param {number} state A number representing one of the button state consts.
*/ */
this.emit("button", Consts.ButtonStates.PRESSED); this.emit("button", Consts.ButtonStates.PRESSED);
return; return;
@ -286,7 +286,7 @@ export class BoostHub extends Hub {
* Emits when a distance sensor is activated. * Emits when a distance sensor is activated.
* @event BoostHub#distance * @event BoostHub#distance
* @param {string} port * @param {string} port
* @param {number} distance - Distance, in millimeters. * @param {number} distance Distance, in millimeters.
*/ */
this.emit("distance", port.id, distance * 10); this.emit("distance", port.id, distance * 10);
break; break;
@ -298,7 +298,7 @@ export class BoostHub extends Hub {
* Emits when a color sensor is activated. * Emits when a color sensor is activated.
* @event BoostHub#color * @event BoostHub#color
* @param {string} port * @param {string} port
* @param {number} color - A number representing one of the LED color consts. * @param {number} color A number representing one of the LED color consts.
*/ */
this.emit("color", port.id, data[4]); this.emit("color", port.id, data[4]);

View File

@ -53,8 +53,8 @@ export class WeDo2Hub extends Hub {
/** /**
* Set the color of the LED on the Hub via a color value. * Set the color of the LED on the Hub via a color value.
* @method WeDo2Hub#setLEDColor * @method WeDo2Hub#setLEDColor
* @param {number} color - A number representing one of the LED color consts. * @param {number} color A number representing one of the LED color consts.
* @returns {Promise} - Resolved upon successful completion of command. * @returns {Promise} Resolved upon successful completion of command.
*/ */
public setLEDColor (color: number | boolean) { public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -80,7 +80,7 @@ export class WeDo2Hub extends Hub {
* @param {number} red * @param {number} red
* @param {number} green * @param {number} green
* @param {number} blue * @param {number} blue
* @returns {Promise} - Resolved upon successful completion of command. * @returns {Promise} Resolved upon successful completion of command.
*/ */
public setLEDRGB (red: number, green: number, blue: number) { public setLEDRGB (red: number, green: number, blue: number) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -101,8 +101,8 @@ export class WeDo2Hub extends Hub {
* Set the motor speed on a given port. * Set the motor speed on a given port.
* @method WeDo2Hub#setMotorSpeed * @method WeDo2Hub#setMotorSpeed
* @param {string} port * @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} 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. * @returns {Promise} Resolved upon successful completion of command.
*/ */
public setMotorSpeed (port: string, speed: number) { public setMotorSpeed (port: string, speed: number) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -169,7 +169,7 @@ export class WeDo2Hub extends Hub {
/** /**
* Emits when a button is pressed. * Emits when a button is pressed.
* @event WeDo2Hub#button * @event WeDo2Hub#button
* @param {number} state - A number representing one of the button state consts. * @param {number} state A number representing one of the button state consts.
*/ */
this.emit("button", Consts.ButtonStates.PRESSED); this.emit("button", Consts.ButtonStates.PRESSED);
return; return;
@ -196,7 +196,7 @@ export class WeDo2Hub extends Hub {
* Emits when a distance sensor is activated. * Emits when a distance sensor is activated.
* @event WeDo2Hub#distance * @event WeDo2Hub#distance
* @param {string} port * @param {string} port
* @param {number} distance - Distance, in millimeters. * @param {number} distance Distance, in millimeters.
*/ */
this.emit("distance", port.id, distance * 10); this.emit("distance", port.id, distance * 10);
break; break;
@ -208,7 +208,7 @@ export class WeDo2Hub extends Hub {
* Emits when a color sensor is activated. * Emits when a color sensor is activated.
* @event WeDo2Hub#color * @event WeDo2Hub#color
* @param {string} port * @param {string} port
* @param {number} color - A number representing one of the LED color consts. * @param {number} color A number representing one of the LED color consts.
*/ */
this.emit("color", port.id, distance); this.emit("color", port.id, distance);
break; break;