# network-status

> Monitoring for network status and for re-connect

Latest version **1.0.2** (published 2015-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install network-status
pnpm add network-status
yarn add network-status
bun add network-status
```

## 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.2 |
| Published | 2015-12-08 |
| First published | 2015-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sten |
| Maintainers | mybuilder |
| Keywords | network monitor |

## Links

- npm: https://www.npmjs.com/package/network-status
- Repository: https://github.com/mybuilder/network-status
- Homepage: https://github.com/mybuilder/network-status#readme
- Issues: https://github.com/mybuilder/network-status/issues
- npm.io page: https://npm.io/package/network-status

## Recent versions

- 1.0.2 (latest) — 2015-12-08

## README

Network status
--------------

Allows checking the network status and re-connect.

Requires ES6 Promises

[![Build Status](https://travis-ci.org/mybuilder/network-status.svg?branch=master)](https://travis-ci.org/mybuilder/network-status)

## Install from npm
```
npm install network-status --save
```


## Network status

From network `networkStatus` returns the current network state by giving a uri to ping e.g. `favicon.ico`.

```javascript
networkStatus('/favicon.ico')
    .then(isReachable)
    .catch(notReachable);
```

If the network connection is lost you can create a monitor for re-connection.

```javascript
let networkStatusFavicon = () => networkStatus('/favicon.ico');

networkStatusFaviconIco()
    .then(isReachable)
    .catch(error => {
        // update the UI to notify the user about lost network connection

        return monitorForReConnect({
            networkStatus: networkStatusFavicon,
            maxRetries: 100});
    })
    .then(() => {
        // update the UI, connection has been restored
    })
    .catch(error => {
        // maximum retries reached
    });
```

* `networkStatus` must be a function without arguments
* `maxRetries` if is set to 0 or `undefined` it will try forever (default: `undefined`)
* `delay` how long should be between network pings in milliseconds (default: `2000`)

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