is-reachable
Check if servers are reachable
Works in Node.js and the browser (with browserify).
Install
$ npm install --save is-reachable
Usage
var isReachable = require('is-reachable');
isReachable('sindresorhus.com', function (err, reachable) {
console.log(reachable);
});
isReachable('google.com:80', function (err, reachable) {
console.log(reachable);
});
Node.js API
isReachable(hosts, callback)
hosts
Type: string
, array
One or more hosts to check.
callback(error, reachable)
Type: function
error
is there only by Node.js convention and is always null
.
reachable
Type: boolean
Is true
if any of the hosts
are reachable.
Browser API
Same as above except the callback
doesn't have an error
parameter.
Contributors
Related
- is-online - Check if the internet connection is up
License
MIT © Sindre Sorhus