nyc-bookstores/node_modules/hasinternet/index.js
2013-05-27 13:45:59 -07:00

12 lines
305 B
JavaScript

var dns = require('dns')
module.exports = hasInternet
function hasInternet(cb) {
if (process.browser) return cb(false, navigator.onLine)
dns.lookup('www.google.com', function(err, addresses) {
if (err) return cb(err, false) // an error, no www
return cb(false, true) // no error, has www
})
}