Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/feross/connectivity
Detect if the network is up (do we have connectivity?)
https://github.com/feross/connectivity
browser browserify connection detect javascript network nodejs
Last synced: 28 days ago
JSON representation
Detect if the network is up (do we have connectivity?)
- Host: GitHub
- URL: https://github.com/feross/connectivity
- Owner: feross
- License: mit
- Created: 2014-04-15T07:20:03.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-06-29T07:56:50.000Z (5 months ago)
- Last Synced: 2024-10-11T14:08:51.353Z (about 1 month ago)
- Topics: browser, browserify, connection, detect, javascript, network, nodejs
- Language: JavaScript
- Homepage:
- Size: 74.2 KB
- Stars: 62
- Watchers: 5
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# connectivity [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/connectivity/master.svg
[travis-url]: https://travis-ci.org/feross/connectivity
[npm-image]: https://img.shields.io/npm/v/connectivity.svg
[npm-url]: https://npmjs.org/package/connectivity
[downloads-image]: https://img.shields.io/npm/dm/connectivity.svg
[downloads-url]: https://npmjs.org/package/connectivity
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com#### Detect if the network is up (do we have connectivity?)
![internet!](https://raw.githubusercontent.com/feross/connectivity/master/img.jpg)
The module answers the most important question: is the cat-picture delivery system working?
### usage
```js
var connectivity = require('connectivity')connectivity(function (online) {
if (online) {
console.log('connected to the internet!')
} else {
console.error('sorry, not connected!')
}
})
```Also works in the browser with [browserify](http://browserify.org/)!
### license
MIT. Copyright [Feross Aboukhadijeh](https://www.twitter.com/feross).