JSPM

  • Created
  • Published
  • Downloads 93551
  • Score
    100M100P100Q149562F
  • License MIT

Check if you're online

Package Exports

  • is-online
  • is-online/browser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-online) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-online Build Status

Check if you're online

Works in Node.js, CLI and the browser (with browserify).

In the browser you have navigator.onLine, but it's useless as it only tells you if there's a local connection, and not whether the internet is accessible.

Install

$ npm install --save is-online

Usage

var isOnline = require('is-online');

isOnline(err, online) {
    console.log(online);
    //=> true
});

API

isOnline([domain], callback)

domain

Optional
Type: string
Default 'google.com' (recommend not to change this)

When used in the browser, make sure the domain you choose has a favicon.ico in the root.

callback(error, online)

Required
Type: function

error is there only by Node.js convention and is always null.

CLI

$ npm install --global is-online
$ is-online --help

  Example
    is-online
    ✔︎ Online

License

MIT © Sindre Sorhus