Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-ble

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ble - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

20

package.json
{
"name": "node-ble",
"description": "Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus",
"version": "1.7.0",
"version": "1.8.0",
"repository": "https://github.com/chrvadala/node-ble.git",

@@ -41,10 +41,10 @@ "author": "chrvadala",

"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.5",
"@babel/plugin-proposal-decorators": "^7.16.5",
"@types/jest": "^27.0.3",
"@types/node": "^17.0.5",
"jest": "^27.4.5",
"jsdoc-to-markdown": "^7.1.0",
"standard": "^16.0.4",
"typescript": "^4.5.4"
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.20.0",
"@types/jest": "^29.2.0",
"@types/node": "^18.11.7",
"jest": "^29.2.2",
"jsdoc-to-markdown": "^7.1.1",
"standard": "^17.0.0",
"typescript": "^4.8.4"
},

@@ -57,3 +57,3 @@ "standard": {

},
"funding": "https://www.paypal.me/chrvadala/25"
"funding": "https://github.com/sponsors/chrvadala"
}

@@ -10,3 +10,3 @@ # node-ble

[![Downloads](https://img.shields.io/npm/dm/node-ble.svg)](https://www.npmjs.com/package/node-ble)
[![Donate](https://img.shields.io/badge/donate-PayPal-green.svg)](https://www.paypal.me/chrvadala/25)
[![Donate](https://img.shields.io/badge/donate-GithubSponsor-green.svg)](https://github.com/sponsors/chrvadala)

@@ -109,7 +109,4 @@

*Node-ble* has been tested on the following environment:
- Raspbian GNU/Linux 10 (buster)
- Ubuntu 18.04.4 LTS
- Ubuntu 20.04 LTS
- Ubuntu 21.10
- Raspbian
- Ubuntu
# Changelog

@@ -125,2 +122,3 @@ - **0.x** - Beta version

- **1.7** - Fixes compatibility issue [#30](https://github.com/chrvadala/node-ble/issues/30); Adds JSdoc; Deprecates NodeJS 10 and 12; Upgrades deps;
- **1.8** - Upgrades deps and gh-actions os; Adds `Bluetooth.activeAdapters()` func [#45](https://github.com/chrvadala/node-ble/pull/45);

@@ -131,2 +129,3 @@ # Contributors

- [lupol](https://github.com/lupol)
- [altaircunhajr](https://github.com/altaircunhajr)

@@ -133,0 +132,0 @@ # References

@@ -54,4 +54,22 @@ const BusHelper = require('./BusHelper')

}
/**
* List all available (powered) adapters
* @async
* @returns {Promise<Adapter[]>}
*/
async activeAdapters () {
const adapterNames = await this.adapters()
const allAdapters = await Promise.allSettled(adapterNames.map(async name => {
const adapter = await this.getAdapter(name)
const isPowered = await adapter.isPowered()
return { adapter, isPowered }
}))
return allAdapters
.filter(item => item.status === 'fulfilled' && item.value.isPowered)
.map(item => item.value.adapter)
}
}
module.exports = Bluetooth

@@ -47,1 +47,24 @@ /* global describe, test, expect, it, jest */

})
describe('getActiveAdapters', () => {
it('should return only active adapters', async () => {
const hci0 = new Adapter(dbus, 'hci0')
hci0.isPowered = async () => false
hci0.getName = async () => 'hci0'
const hci1 = new Adapter(dbus, 'hci1')
hci1.isPowered = async () => true
hci1.getName = async () => 'hci1'
const bluetooth = new Bluetooth(dbus)
const adapters = { hci0, hci1 }
bluetooth.getAdapter = async name => adapters[name]
bluetooth.helper.children.mockReturnValue(['hci0', 'hci1'])
const result = await bluetooth.activeAdapters()
expect(result.length).toEqual(1)
await expect(result[0].getName()).resolves.toEqual('hci1')
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc