feross/connectivity

Optional url param

Opened this issue · 1 comments

I think it would be a good feature to allow users have an optional object parameter to check if they can connect to a server. This would be useful for websites that might sometimes be down or to check if a server on localhost is running.

var connectivity = require('connectivity')

connectivity({host: 'localhost', port: 8000}, (online) => {
    console.log(online ? 'connected to the internet!' : 'sorry, not connected!')
})

The object parameter would be optional, if there is no second parameter it would be assumed that the first parameter is the callback.

This is a great idea. If you would like to see it implemented, please send a pull request!

mickey-wizard