bluetooth-terminal
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"extends": [ | ||
"eslint:recommended", | ||
"google" | ||
], | ||
"env": { | ||
@@ -11,3 +7,7 @@ "browser": true, | ||
"node": true | ||
} | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"google" | ||
] | ||
} |
{ | ||
"name": "bluetooth-terminal", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "ES6 class for serial communication with Bluetooth Low Energy (Smart) devices", | ||
"main": "./src/BluetoothTerminal.js", | ||
"scripts": { | ||
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha", | ||
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"lint": "eslint ./src/ ./test/", | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/1oginov/bluetooth-terminal.git" | ||
}, | ||
"keywords": [ | ||
"ble", | ||
"bluetooth", | ||
"communication", | ||
"iot", | ||
"serial", | ||
"communication", | ||
"bluetooth", | ||
"ble", | ||
"smart", | ||
"iot" | ||
"smart" | ||
], | ||
"main": "BluetoothTerminal.js", | ||
"homepage": "https://github.com/1oginov/bluetooth-terminal", | ||
"author": "Danila Loginov <danila@loginov.rocks> (https://loginov.rocks)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/1oginov/bluetooth-terminal/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/1oginov/bluetooth-terminal.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Danila Loginov <danila@loginov.rocks> (https://loginov.rocks)", | ||
"homepage": "https://github.com/1oginov/bluetooth-terminal", | ||
"devDependencies": { | ||
@@ -28,16 +34,10 @@ "chai": "^4.1.2", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.12.1", | ||
"eslint": "^4.17.0", | ||
"eslint-config-google": "^0.9.1", | ||
"istanbul": "^0.4.5", | ||
"jsdom": "^11.5.1", | ||
"mocha": "^4.0.1", | ||
"sinon": "^4.1.2", | ||
"jsdom": "^11.6.2", | ||
"mocha": "^5.0.0", | ||
"sinon": "^4.2.2", | ||
"web-bluetooth-mock": "^1.0.2" | ||
}, | ||
"scripts": { | ||
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha", | ||
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"lint": "eslint BluetoothTerminal.js test/", | ||
"test": "mocha" | ||
} | ||
} |
@@ -21,6 +21,7 @@ # bluetooth-terminal | ||
You can use script directly or install it using [npm](https://npmjs.com) and require in your scripts. | ||
You can use the [script](https://github.com/1oginov/bluetooth-terminal/blob/master/src/BluetoothTerminal.js) directly or | ||
install it using [npm](https://npmjs.com) and require in your code. | ||
```sh | ||
$ npm install bluetooth-terminal | ||
npm install bluetooth-terminal | ||
``` | ||
@@ -30,7 +31,7 @@ | ||
```javascript | ||
// Obtain configured instance | ||
```js | ||
// Obtain configured instance. | ||
let terminal = new BluetoothTerminal(); | ||
// Override `receive` method to handle incoming data as you want | ||
// Override `receive` method to handle incoming data as you want. | ||
terminal.receive = function(data) { | ||
@@ -40,3 +41,3 @@ alert(data); | ||
// Request the device for connection and get its name after successful connection | ||
// Request the device for connection and get its name after successful connection. | ||
terminal.connect().then(() => { | ||
@@ -46,6 +47,6 @@ alert(terminal.getDeviceName() + ' is connected!'); | ||
// Send something to the connected device | ||
// Send something to the connected device. | ||
terminal.send('Simon says: Hello, world!'); | ||
// Disconnect from the connected device | ||
// Disconnect from the connected device. | ||
terminal.disconnect(); | ||
@@ -69,7 +70,7 @@ ``` | ||
* [setSendDelay(delay)](#setsenddelaydelay) | ||
* [connect() ⇒ `Promise`](#connect--promise) | ||
* [connect() ⇒ Promise](#connect--promise) | ||
* [disconnect()](#disconnect) | ||
* [receive(data)](#receivedata) | ||
* [send(data) ⇒ `Promise`](#senddata--promise) | ||
* [getDeviceName() ⇒ `string`](#getdevicename--string) | ||
* [send(data) ⇒ Promise](#senddata--promise) | ||
* [getDeviceName() ⇒ string](#getdevicename--string) | ||
@@ -159,3 +160,3 @@ --- | ||
**Returns**: `Promise` - Promise which will be fulfilled when notifications will be started or rejected if something | ||
went wrong | ||
went wrong | ||
@@ -191,3 +192,3 @@ --- | ||
**Returns**: `Promise` - Promise which will be fulfilled when data will be sent or rejected if something went wrong | ||
**Returns**: `Promise` - Promise which will be fulfilled when data will be sent or rejected if something went wrong | ||
@@ -210,2 +211,2 @@ | Parameter | Type | Description | | ||
If you want to contribute, please use the [dev](https://github.com/1oginov/bluetooth-terminal/tree/dev/) branch. | ||
If you want to contribute, please use the [dev](https://github.com/1oginov/bluetooth-terminal/tree/dev) branch. |
@@ -0,21 +1,22 @@ | ||
'use strict'; | ||
const chai = require('chai'); | ||
const chaiAsPromised = require('chai-as-promised'); | ||
const {DeviceMock, WebBluetoothMock} = require('web-bluetooth-mock'); | ||
const {JSDOM} = require('jsdom'); | ||
const path = require('path'); | ||
const sinon = require('sinon'); | ||
const {TextDecoder, TextEncoder} = require('util'); | ||
const {DeviceMock, WebBluetoothMock} = require('web-bluetooth-mock'); | ||
const BluetoothTerminal = require('../src/BluetoothTerminal'); | ||
chai.use(chaiAsPromised); | ||
const {assert} = chai; | ||
const BluetoothTerminal = require(path.join(__dirname, '..', | ||
'BluetoothTerminal')); | ||
// Provide testing environment with `window` object to support DOM events and | ||
// with `navigator` to spy for bluetooth features | ||
// with `navigator` to spy for bluetooth features. | ||
global.window = new JSDOM('').window; | ||
global.navigator = window.navigator; | ||
// Use node text encoding features from `util` module | ||
// Use node text encoding features from `util` module. | ||
global.TextDecoder = TextDecoder; | ||
@@ -27,3 +28,3 @@ global.TextEncoder = TextEncoder; | ||
// Create new instance before each test | ||
// Create new instance before each test. | ||
beforeEach(() => { | ||
@@ -181,3 +182,3 @@ bt = new BluetoothTerminal(); | ||
// Connect to the device and set up the spy before each test | ||
// Connect to the device and set up the spy before each test. | ||
beforeEach(() => { | ||
@@ -194,3 +195,3 @@ device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
bt.disconnect(); | ||
bt.disconnect(); // Second call should not fire disconnect method | ||
bt.disconnect(); // Second call should not fire disconnect method. | ||
return assert(disconnectSpy.calledOnce); | ||
@@ -204,3 +205,3 @@ }); | ||
then(() => { | ||
// Hard mock used here to cover the case | ||
// Hard mock used here to cover the case. | ||
bt._device.gatt.connected = false; | ||
@@ -219,3 +220,3 @@ bt.disconnect(); | ||
// Connect to the device and set up the spy before each test | ||
// Connect to the device and set up the spy before each test. | ||
beforeEach(() => { | ||
@@ -275,3 +276,3 @@ const device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
describe('send', () => { | ||
// Set up Web Bluetooth mock before each test | ||
// Set up Web Bluetooth mock before each test. | ||
beforeEach(() => { | ||
@@ -337,3 +338,3 @@ const device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
describe('getDeviceName', () => { | ||
// Set up Web Bluetooth mock before each test | ||
// Set up Web Bluetooth mock before each test. | ||
beforeEach(() => { | ||
@@ -362,3 +363,3 @@ const device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
// Connect to the device and set up the spy before each test | ||
// Connect to the device and set up the spy before each test. | ||
beforeEach(() => { | ||
@@ -386,3 +387,3 @@ const device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
then(() => { | ||
// Call for private method only to test it | ||
// Call for private method only to test it. | ||
return bt._stopNotifications(bt._characteristic); | ||
@@ -394,3 +395,3 @@ }). | ||
return assert(receiveSpy.calledOnce); // Remains the same | ||
return assert(receiveSpy.calledOnce); // Remains the same. | ||
}); | ||
@@ -407,3 +408,3 @@ }); | ||
// Set up Web Bluetooth mock before each test | ||
// Set up Web Bluetooth mock before each test. | ||
beforeEach(() => { | ||
@@ -439,3 +440,3 @@ device = new DeviceMock('Simon', [bt._serviceUuid]); | ||
then(() => { | ||
// Simulate disconnection | ||
// Simulate disconnection. | ||
device.gatt.connected = false; | ||
@@ -446,3 +447,3 @@ device.gatt.connect = () => Promise.reject(error); | ||
then(() => { | ||
// Make sure the assert will be executed after the promise | ||
// Make sure the assert will be executed after the promise. | ||
setTimeout(() => { | ||
@@ -449,0 +450,0 @@ assert(logSpy.lastCall.calledWith(error)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
40187
205
0
15
747
1