Files
fitness_walk_nwnu/node_modules/adb-devices-emitter/README.md
T
2026-09-08 20:28:54 +08:00

46 lines
1019 B
Markdown

# adb-devices-emitter
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Track insertion device status
## Examples
### add event listener `deviceAdded` `deviceRemoved`
```javascript
const devicesEmitter = require('adb-devices-emitter')
devicesEmitter.on('deviceAdded', ({ sn }) => {
console.log('deviceAdded sn:', sn)
})
devicesEmitter.on('deviceRemoved', ({ sn }) => {
console.log('deviceRemoved sn:', sn)
})
devicesEmitter.start()
```
### stop
```javascript
const devicesEmitter = require('adb-devices-emitter')
devicesEmitter.on('deviceAdded', ({ sn }) => {
console.log('deviceAdded sn:', sn)
})
devicesEmitter.on('deviceRemoved', ({ sn }) => {
console.log('deviceRemoved sn:', sn)
})
devicesEmitter.start()
setTimeout(() => {
console.log('stop')
devicesEmitter.stop()
}, 100000)
```