🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

connection-state

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connection-state - npm Package Compare versions

Comparing version

to
0.0.2

2

package.json
{
"name": "connection-state",
"version": "0.0.1",
"version": "0.0.2",
"description": "Detect online and offline network state.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -13,2 +13,18 @@ # Connection state [![npm](https://img.shields.io/npm/v/connection-state.svg)](https://www.npmjs.com/package/connection-state) ![npm type definitions](https://img.shields.io/npm/types/connection-state.svg)

## Usage
```js
import { connectionState } from 'connection-state'
const connection = connectionState()
console.log(`You are ${connection.getState()}.`)
// connection.getState() returns 'online' or 'offline'
connection.addListener((state) => {
console.log(`Your connection state has changed. You are now ${state}.`)
})
// state is 'online' or 'offline'
```
## Development

@@ -15,0 +31,0 @@