cordova-plugin-ble-central
Advanced tools
Comparing version 1.7.3 to 1.7.4-slim
@@ -0,1 +1,5 @@ | ||
## 1.7.4 | ||
- More cleanly support isConnected usage with a bool return value #1018 with review from @MaximBelov | ||
## 1.7.3 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "cordova-plugin-ble-central", | ||
"version": "1.7.3", | ||
"version": "1.7.4-slim", | ||
"description": "Bluetooth Low Energy (BLE) Central Plugin", | ||
@@ -18,2 +18,3 @@ "scripts": { | ||
"publishConfig": { | ||
"tag": "slim", | ||
"registry": "https://registry.npmjs.org" | ||
@@ -20,0 +21,0 @@ }, |
@@ -841,5 +841,10 @@ # Bluetooth Low Energy (BLE) Central Plugin for Apache Cordova | ||
```javascript | ||
// Callbacks | ||
ble.isConnected(device_id, success, failure); | ||
// Or using await with promises | ||
await ble.withPromises.isConnected(device_id); | ||
// Promises with boolean return | ||
const isConnected = await ble.withPromises.isConnected(device_id, false); | ||
// Promises with rejection | ||
await ble.withPromises.isConnected(device_id); // throws if not connected | ||
``` | ||
@@ -862,2 +867,3 @@ | ||
```javascript | ||
// Callbacks | ||
ble.isConnected( | ||
@@ -872,2 +878,18 @@ 'FFCA0B09-CB1D-4DC0-A1EF-31AFD3EDFB53', | ||
); | ||
// Promises with boolean return | ||
const isConnected = await ble.withPromises.isConnected(device_id, false); | ||
if (isConnected) { | ||
console.log('Peripheral is connected'); | ||
} else { | ||
console.log('Peripheral is *not* connected'); | ||
} | ||
// Promises with rejection | ||
try { | ||
await ble.withPromises.isConnected(device_id); | ||
console.log('Peripheral is connected'); | ||
} catch (e) { | ||
console.log('Peripheral is *not* connected'); | ||
} | ||
``` | ||
@@ -1618,5 +1640,3 @@ | ||
1. `npm version patch` | ||
2. Align `plugin.xml` version with npm version | ||
3. Update release notes based on `git log --oneline --no-merges <last release>...master` | ||
4. `npm publish` | ||
2. `npm publish` | ||
@@ -1623,0 +1643,0 @@ ## Release (slim) |
@@ -163,5 +163,10 @@ declare namespace BLECentralPlugin { | ||
/* Returns a rejected promise if the device is not connected */ | ||
/* Returns a resolved promise if the device is connected, | ||
otherwise returns rejected promise if the device is not connected */ | ||
isConnected(device_id: string): Promise<void>; | ||
/* Returns a promise that resolves to true if the device is connected, | ||
otherwise resolves to false if the device is not connected or an error occurs */ | ||
isConnected(device_id: string, rejectWhenDisconnected: false): Promise<boolean>; | ||
/* Returns a rejected promise if bluetooth is not connected */ | ||
@@ -168,0 +173,0 @@ isEnabled(): Promise<void>; |
@@ -365,5 +365,13 @@ // (c) 2014-2016 Don Coleman | ||
isConnected: function (device_id) { | ||
isConnected: function (device_id, rejectWhenDisconnected) { | ||
return new Promise(function (resolve, reject) { | ||
module.exports.isConnected(device_id, resolve, reject); | ||
if (rejectWhenDisconnected === false) { | ||
module.exports.isConnected( | ||
device_id, | ||
() => resolve(true), | ||
() => resolve(false) | ||
); | ||
} else { | ||
module.exports.isConnected(device_id, resolve, reject); | ||
} | ||
}); | ||
@@ -370,0 +378,0 @@ }, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1664
0
335428
23
981
1