Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

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

## [Version 1.6.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.5.0) (2022-10-18)
## [Version 1.6.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.6.1) (2022-10-18)

## What's Changed

- Fixed Issue where node-switchbot wouldn't be found.

**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.6.0...v1.6.1

## [Version 1.6.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.6.0) (2022-10-18)

## What's Changed

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Monitoring the advertising packets, you can find your devices and know the lates

```JavaScript
// Load the node-switchbot and get a `Switchbot` constructor object
const Switchbot = require('node-switchbot');
let Switchbot = require('node-switchbot');
// Create an `Switchbot` object
const switchbot = new Switchbot();
let switchbot = new Switchbot();

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

```javascript
// Load the node-switchbot and get a `Switchbot` constructor object
const Switchbot = require("node-switchbot");
let Switchbot = require("node-switchbot");
// Create an `Switchbot` object
let switchbot = new Switchbot();

Expand Down Expand Up @@ -213,13 +213,13 @@ This sample discovers a Bot (WoHand), then put the Bot's arm down, finally put i

```javascript
// Load the node-switchbot and get a `Switchbot` constructor object
const Switchbot = require("node-switchbot");
let Switchbot = require("node-switchbot");
// Create an `Switchbot` object
const switchbot = new Switchbot();
let switchbot = new Switchbot();

(async () => {
// Find a Bot (WoHand)
const bot_list = await switchbot.discover({ model: "H", quick: true });
let bot_list = await switchbot.discover({ model: "H", quick: true });
if (bot_list.length === 0) {
throw new Error("No device was found.");
}
Expand All @@ -246,13 +246,13 @@ In this code, you can get a [`SwitchbotDeviceWoHand`](#SwitchbotDeviceWoHand-obj
In order to use the node-switchbot, you have to load the node-switchbot module as follows:

```JavaScript
const Switchbot = require('node-switchbot');
let Switchbot = require('node-switchbot');
```

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

```javascript
const switchbot = new Switchbot();
let switchbot = new Switchbot();
```

The `Switchbot` constructor takes an argument optionally. It must be a hash object containing the properties as follows:
Expand All @@ -267,11 +267,11 @@ The sample code below shows how to pass a `Nobel` object to the `Switchbot` cons

```JavaScript
// Create a Noble object
const noble = require('@abandonware/noble');
let noble = require('@abandonware/noble');

// Create a Switchbot object
const Switchbot = require('node-switchbot');
const switchbot = new Switchbot({'noble': noble});
let Switchbot = require('node-switchbot');
let switchbot = new Switchbot({'noble': noble});
```

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.
Expand Down
20 changes: 10 additions & 10 deletions lib/parameter-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ParameterChecker {
* an `Error` object will be set to `this._error`.
*
* [Usage]
* const valid = parameterChecker.check(params, {
* let valid = parameterChecker.check(params, {
* level: {
* required: false,
* type: 'integer',
Expand All @@ -50,7 +50,7 @@ class ParameterChecker {
* }
* });
* if(!valid) {
* const e = parameterChecker.error.message;
* let e = parameterChecker.error.message;
* throw new Error(message);
* }
* ---------------------------------------------------------------- */
Expand Down Expand Up @@ -78,13 +78,13 @@ class ParameterChecker {
return false;
}

const result = true;
const name_list = Object.keys(rules);
let result = true;
let name_list = Object.keys(rules);

for (const i = 0; i < name_list.length; i++) {
const name = name_list[i];
const v = obj[name];
const rule = rules[name];
for (let i = 0; i < name_list.length; i++) {
let name = name_list[i];
let v = obj[name];
let rule = rules[name];

if (!rule) {
rule = {};
Expand Down Expand Up @@ -458,7 +458,7 @@ class ParameterChecker {
}
}
if (typeof rule.minBytes === "number") {
const blen = Buffer.from(value, "utf8").length;
let blen = Buffer.from(value, "utf8").length;
if (blen < rule.minBytes) {
this._error = {
code: "LENGTH_UNDERFLOW",
Expand All @@ -475,7 +475,7 @@ class ParameterChecker {
}
}
if (typeof rule.maxBytes === "number") {
const blen = Buffer.from(value, "utf8").length;
let blen = Buffer.from(value, "utf8").length;
if (blen > rule.maxBytes) {
this._error = {
code: "LENGTH_OVERFLOW",
Expand Down
Loading