# connectivity-events

> Emits events on system wakeup or network status changes.

Latest version **1.0.3** (published 2020-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install connectivity-events
pnpm add connectivity-events
yarn add connectivity-events
bun add connectivity-events
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-02-13 |
| First published | 2020-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Andrew Osheroff |
| Maintainers | andrewosh |
| Keywords | network, connectivty, events |

## Links

- npm: https://www.npmjs.com/package/connectivity-events
- Repository: https://github.com/andrewosh/connectivity-events
- Homepage: https://github.com/andrewosh/connectivity-events#readme
- Issues: https://github.com/andrewosh/connectivity-events/issues
- npm.io page: https://npm.io/package/connectivity-events

## Dependencies (1)

- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^3.1.1

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-02-13
- 1.0.2 — 2020-02-13
- 1.0.1 — 2020-02-13
- 1.0.0 — 2020-02-13

## README

# connectivity-events
Emits events on system wakeup or network status changes.

By default, the timer that's used for polling `os.networkInterfaces()` is unref'd, so it won't keep your process alive.

### Installation
```
> npm i connectivity-events --save
```

### Usage
```js
const ConnectivityMonitor = require('connectivity-events')
const connectivity = new ConnectivityMonitor()

connectivity.on('change', () => { ... }) // Emitted whenever connectivity state changes.

// After you're done listening for events.
connectivity.destroy()
```

### API
#### `const monitor = new ConnectivityMonitor(opts = {})`
Start listening for connectivity events.

Options include:
```js
{
  interval: 10000 // The default polling interval.
  noUnref: false  // Don't unref the timer.
}
```

#### `monitor.on('change', () => { ... })`
Emitted whenever your computer's connectivity state has changed.

This will also be emitted when your computer wakes up after being suspended.

#### `monitor.destroy()`
Stop listening for network changes.

### License
MIT

---
_Source: https://npm.io/package/connectivity-events · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
