Skip to content

Commit 17bdf8a

Browse files
v1.8.1 (#186)
## [Version 1.8.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.8.1) (2023-04-08) ## What's Changed - Use const keyword for immutable variables, Thanks [@dnicolson](https://github.com/dnicolson/). [#184](#184) - Use Error object for promise rejection, Thanks [@dnicolson](https://github.com/dnicolson/). [#181](#181) - Housekeeping and update dependencies **Full Changelog**: v1.8.0...v1.8.1
1 parent 8511ea5 commit 17bdf8a

17 files changed

+697
-435
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
44

5+
## [Version 1.8.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.8.1) (2023-04-08)
6+
7+
## What's Changed
8+
- Use const keyword for immutable variables, Thanks [@dnicolson](https://github.com/dnicolson/). [#184](https://github.com/OpenWonderLabs/node-switchbot/pull/184)
9+
- Use Error object for promise rejection, Thanks [@dnicolson](https://github.com/dnicolson/). [#181](https://github.com/OpenWonderLabs/node-switchbot/pull/181)
10+
- Housekeeping and update dependencies
11+
12+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.8.0...v1.8.1
13+
514
## [Version 1.8.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.8.0) (2023-01-28)
615

716
## What's Changed
817

918
- Add Support for BlindTilt (Read Only)
10-
- Use Error object for promise rejection, Thanks [@dnicolson](https://github.com/dnicolson/). [#181](https://github.com/OpenWonderLabs/node-switchbot/pull/181)
19+
- Use Error object for promise rejection, Thanks [@dnicolson](https://github.com/dnicolson/). [#181](https://github.com/OpenWonderLabs/node-switchbot/pull/181)
1120
- Housekeeping and update dependencies
1221

1322
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.7.3...v1.8.0
@@ -16,7 +25,7 @@ All notable changes to this project will be documented in this file. This projec
1625

1726
## What's Changed
1827

19-
- Improve error handling, Thanks [@dnicolson](https://github.com/dnicolson/). [#175](https://github.com/OpenWonderLabs/node-switchbot/pull/175)
28+
- Improve error handling, Thanks [@dnicolson](https://github.com/dnicolson/). [#175](https://github.com/OpenWonderLabs/node-switchbot/pull/175)
2029
- Housekeeping and update dependencies
2130

2231
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.7.2...v1.7.3

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ Monitoring the advertising packets, you can find your devices and know the lates
110110

111111
```JavaScript
112112
// Load the node-switchbot and get a `Switchbot` constructor object
113-
let Switchbot = require('node-switchbot');
113+
const Switchbot = require('node-switchbot');
114114
// Create an `Switchbot` object
115-
let switchbot = new Switchbot();
115+
const switchbot = new Switchbot();
116116

117117
(async () => {
118118
// Start to monitor advertisement packets
@@ -137,9 +137,9 @@ The [`startScan()`](#startscan-method) and [`wait()`](#Switchbot-wait-method) me
137137

138138
```javascript
139139
// Load the node-switchbot and get a `Switchbot` constructor object
140-
let Switchbot = require("node-switchbot");
140+
const Switchbot = require("node-switchbot");
141141
// Create an `Switchbot` object
142-
let switchbot = new Switchbot();
142+
const switchbot = new Switchbot();
143143

144144
// Start to monitor advertisement packets
145145
switchbot
@@ -213,18 +213,18 @@ This sample discovers a Bot (WoHand), then put the Bot's arm down, finally put i
213213

214214
```javascript
215215
// Load the node-switchbot and get a `Switchbot` constructor object
216-
let Switchbot = require("node-switchbot");
216+
const Switchbot = require("node-switchbot");
217217
// Create an `Switchbot` object
218-
let switchbot = new Switchbot();
218+
const switchbot = new Switchbot();
219219

220220
(async () => {
221221
// Find a Bot (WoHand)
222-
let bot_list = await switchbot.discover({ model: "H", quick: true });
222+
const bot_list = await switchbot.discover({ model: "H", quick: true });
223223
if (bot_list.length === 0) {
224224
throw new Error("No device was found.");
225225
}
226226
// The `SwitchbotDeviceWoHand` object representing the found Bot.
227-
let device = bot_list[0];
227+
const device = bot_list[0];
228228
// Put the Bot's arm down (stretch the arm)
229229
await device.down();
230230
// Wait for 5 seconds
@@ -246,13 +246,13 @@ In this code, you can get a [`SwitchbotDeviceWoHand`](#SwitchbotDeviceWoHand-obj
246246
In order to use the node-switchbot, you have to load the node-switchbot module as follows:
247247

248248
```JavaScript
249-
let Switchbot = require('node-switchbot');
249+
const Switchbot = require('node-switchbot');
250250
```
251251

252252
You can get an `Switchbot` constructor from the code above. Then you have to create an `Switchbot` object from the `Switchbot` constructor as follows:
253253

254254
```javascript
255-
let switchbot = new Switchbot();
255+
const switchbot = new Switchbot();
256256
```
257257

258258
The `Switchbot` constructor takes an argument optionally. It must be a hash object containing the properties as follows:
@@ -263,15 +263,15 @@ The `Switchbot` constructor takes an argument optionally. It must be a hash obje
263263

264264
The node-switchbot module uses the [`@abandonware/noble`](https://github.com/abandonware/noble) module in order to interact with BLE devices. If you want to interact other BLE devices using the `@abandonware/noble` module, you can create an `Noble` object by yourself, then pass it to this module. If you don't specify a `Noble` object to the `noble` property, this module automatically create a `Noble` object internally.
265265

266-
The sample code below shows how to pass a `Nobel` object to the `Switchbot` constructor.
266+
The sample code below shows how to pass a `Noble` object to the `Switchbot` constructor.
267267

268268
```JavaScript
269269
// Create a Noble object
270-
let noble = require('@abandonware/noble');
270+
const noble = require('@abandonware/noble');
271271

272272
// Create a Switchbot object
273-
let Switchbot = require('node-switchbot');
274-
let switchbot = new Switchbot({'noble': noble});
273+
const Switchbot = require('node-switchbot');
274+
const switchbot = new Switchbot({'noble': noble});
275275
```
276276

277277
In the code snippet above, the variable `switchbot` is an `Switchbot` object. The `Switchbot` object has a lot of methods as described in sections below.
@@ -565,7 +565,7 @@ The code below calls the [`press()`](#SwitchbotDeviceWoHand-press-method) method
565565
switchbot
566566
.discover({ model: "H", quick: true })
567567
.then((device_list) => {
568-
let device = device_list[0];
568+
const device = device_list[0];
569569
if (!device) {
570570
console.log("No device was found.");
571571
process.exit();

lib/parameter-checker.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ParameterChecker {
3737
* an `Error` object will be set to `this._error`.
3838
*
3939
* [Usage]
40-
* let valid = parameterChecker.check(params, {
40+
* const valid = parameterChecker.check(params, {
4141
* level: {
4242
* required: false,
4343
* type: 'integer',
@@ -50,7 +50,7 @@ class ParameterChecker {
5050
* }
5151
* });
5252
* if(!valid) {
53-
* let e = parameterChecker.error.message;
53+
* const e = parameterChecker.error.message;
5454
* throw new Error(message);
5555
* }
5656
* ---------------------------------------------------------------- */
@@ -79,11 +79,11 @@ class ParameterChecker {
7979
}
8080

8181
let result = true;
82-
let name_list = Object.keys(rules);
82+
const name_list = Object.keys(rules);
8383

8484
for (let i = 0; i < name_list.length; i++) {
85-
let name = name_list[i];
86-
let v = obj[name];
85+
const name = name_list[i];
86+
const v = obj[name];
8787
let rule = rules[name];
8888

8989
if (!rule) {
@@ -458,7 +458,7 @@ class ParameterChecker {
458458
}
459459
}
460460
if (typeof rule.minBytes === "number") {
461-
let blen = Buffer.from(value, "utf8").length;
461+
const blen = Buffer.from(value, "utf8").length;
462462
if (blen < rule.minBytes) {
463463
this._error = {
464464
code: "LENGTH_UNDERFLOW",
@@ -475,7 +475,7 @@ class ParameterChecker {
475475
}
476476
}
477477
if (typeof rule.maxBytes === "number") {
478-
let blen = Buffer.from(value, "utf8").length;
478+
const blen = Buffer.from(value, "utf8").length;
479479
if (blen > rule.maxBytes) {
480480
this._error = {
481481
code: "LENGTH_OVERFLOW",

0 commit comments

Comments
 (0)