Added Promise return types to jsdoc

This commit is contained in:
Nathan Kunicki 2018-06-21 10:49:26 +01:00
parent 11556bf292
commit 9ab009b5b4
3 changed files with 24 additions and 12 deletions

View File

@ -45,9 +45,9 @@ Emits when a LPF2 Hub device is found.
**Extends**: [<code>Hub</code>](#Hub) **Extends**: [<code>Hub</code>](#Hub)
* [BoostHub](#BoostHub) ⇐ [<code>Hub</code>](#Hub) * [BoostHub](#BoostHub) ⇐ [<code>Hub</code>](#Hub)
* [.setLEDColor(color)](#BoostHub+setLEDColor) * [.setLEDColor(color)](#BoostHub+setLEDColor)<code>Promise</code>
* [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed) * [.setMotorSpeed(port, speed, [time])](#BoostHub+setMotorSpeed)<code>Promise</code>
* [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle) * [.setMotorAngle(port, angle, [speed])](#BoostHub+setMotorAngle)<code>Promise</code>
* [.connect([callback])](#Hub+connect) * [.connect([callback])](#Hub+connect)
* [.subscribe(port, [mode])](#Hub+subscribe) * [.subscribe(port, [mode])](#Hub+subscribe)
* [.unsubscribe(port)](#Hub+unsubscribe) * [.unsubscribe(port)](#Hub+unsubscribe)
@ -59,10 +59,11 @@ Emits when a LPF2 Hub device is found.
<a name="BoostHub+setLEDColor"></a> <a name="BoostHub+setLEDColor"></a>
### boostHub.setLEDColor(color) ### boostHub.setLEDColor(color)<code>Promise</code>
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.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -70,10 +71,11 @@ Set the color of the LED on the Hub via a color value.
<a name="BoostHub+setMotorSpeed"></a> <a name="BoostHub+setMotorSpeed"></a>
### boostHub.setMotorSpeed(port, speed, [time]) ### boostHub.setMotorSpeed(port, speed, [time])<code>Promise</code>
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.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -83,10 +85,11 @@ Set the motor speed on a given port.
<a name="BoostHub+setMotorAngle"></a> <a name="BoostHub+setMotorAngle"></a>
### boostHub.setMotorAngle(port, angle, [speed]) ### boostHub.setMotorAngle(port, angle, [speed])<code>Promise</code>
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).
| Param | Type | Default | Description | | Param | Type | Default | Description |
| --- | --- | --- | --- | | --- | --- | --- | --- |
@ -196,9 +199,9 @@ Emits when a rotation sensor is activated.
**Extends**: [<code>Hub</code>](#Hub) **Extends**: [<code>Hub</code>](#Hub)
* [WeDo2Hub](#WeDo2Hub) ⇐ [<code>Hub</code>](#Hub) * [WeDo2Hub](#WeDo2Hub) ⇐ [<code>Hub</code>](#Hub)
* [.setLEDColor(color)](#WeDo2Hub+setLEDColor) * [.setLEDColor(color)](#WeDo2Hub+setLEDColor)<code>Promise</code>
* [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB) * [.setLEDRGB(red, green, blue)](#WeDo2Hub+setLEDRGB)<code>Promise</code>
* [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed) * [.setMotorSpeed(port, speed)](#WeDo2Hub+setMotorSpeed)<code>Promise</code>
* [.connect([callback])](#Hub+connect) * [.connect([callback])](#Hub+connect)
* [.subscribe(port, [mode])](#Hub+subscribe) * [.subscribe(port, [mode])](#Hub+subscribe)
* [.unsubscribe(port)](#Hub+unsubscribe) * [.unsubscribe(port)](#Hub+unsubscribe)
@ -210,10 +213,11 @@ Emits when a rotation sensor is activated.
<a name="WeDo2Hub+setLEDColor"></a> <a name="WeDo2Hub+setLEDColor"></a>
### weDo2Hub.setLEDColor(color) ### weDo2Hub.setLEDColor(color)<code>Promise</code>
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.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |
@ -221,10 +225,11 @@ Set the color of the LED on the Hub via a color value.
<a name="WeDo2Hub+setLEDRGB"></a> <a name="WeDo2Hub+setLEDRGB"></a>
### weDo2Hub.setLEDRGB(red, green, blue) ### weDo2Hub.setLEDRGB(red, green, blue)<code>Promise</code>
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.
| Param | Type | | Param | Type |
| --- | --- | | --- | --- |
@ -234,10 +239,11 @@ Set the color of the LED on the Hub via RGB values.
<a name="WeDo2Hub+setMotorSpeed"></a> <a name="WeDo2Hub+setMotorSpeed"></a>
### weDo2Hub.setMotorSpeed(port, speed) ### weDo2Hub.setMotorSpeed(port, speed)<code>Promise</code>
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.
| Param | Type | Description | | Param | Type | Description |
| --- | --- | --- | | --- | --- | --- |

View File

@ -58,6 +58,7 @@ 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.
*/ */
public setLEDColor (color: number | boolean) { public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -93,6 +94,7 @@ export class BoostHub extends Hub {
* @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.
*/ */
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,6 +125,7 @@ export class BoostHub extends Hub {
* @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).
*/ */
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) => {

View File

@ -54,6 +54,7 @@ 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.
*/ */
public setLEDColor (color: number | boolean) { public setLEDColor (color: number | boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -79,6 +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.
*/ */
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) => {
@ -100,6 +102,7 @@ export class WeDo2Hub extends Hub {
* @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.
*/ */
public setMotorSpeed (port: string, speed: number) { public setMotorSpeed (port: string, speed: number) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {