You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

is-online

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-online - npm Package Compare versions

Comparing version
8.5.1
to
9.0.0
+4
-4
browser.js

@@ -8,3 +8,3 @@ /* eslint-env browser */

timeout: 5000,
version: 'v4',
ipVersion: 4,
...options

@@ -17,4 +17,6 @@ };

const publicIpFunctionName = options.ipVersion === 4 ? 'v4' : 'v6';
try {
await publicIp[options.version](options);
await publicIp[publicIpFunctionName](options);
return true;

@@ -27,3 +29,1 @@ } catch (_) {

module.exports = isOnline;
// TODO: Remove this for the next major release
module.exports.default = isOnline;

@@ -13,37 +13,30 @@ declare namespace isOnline {

@default 'v4'
@default 4
*/
readonly version?: 'v4' | 'v6';
readonly ipVersion?: 4 | 6;
}
}
declare const isOnline: {
/**
Check if the internet connection is up.
/**
Check if the internet connection is up.
The following checks are run in parallel:
- Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS
- Query `myip.opendns.com` on OpenDNS (Node.js only)
- Retrieve Apple's Captive Portal test page (Node.js only)
The following checks are run in parallel:
- Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS
- Query `myip.opendns.com` on OpenDNS (Node.js only)
- Retrieve Apple's Captive Portal test page (Node.js only)
When the first check succeeds, the returned Promise is resolved to `true`.
When the first check succeeds, the returned Promise is resolved to `true`.
@example
```
import isOnline = require('is-online');
@example
```
import isOnline = require('is-online');
(async () => {
console.log(await isOnline());
//=> true
})();
```
*/
(options?: isOnline.Options): Promise<boolean>;
(async () => {
console.log(await isOnline());
//=> true
})();
```
*/
declare function isOnline(options?: isOnline.Options): Promise<boolean>;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function isOnline(options?: isOnline.Options): Promise<boolean>;
// export = isOnline;
default: typeof isOnline;
};
export = isOnline;

@@ -14,3 +14,3 @@ 'use strict';

timeout: options.timeout,
family: options.version === 'v4' ? 4 : 6,
dnsLookupIpVersion: options.ipVersion === 6 ? 'ipv6' : 'ipv4',
headers: {

@@ -42,3 +42,3 @@ 'user-agent': 'CaptiveNetworkSupport/1.0 wispr'

timeout: 5000,
version: 'v4',
ipVersion: 4,
...options

@@ -51,2 +51,8 @@ };

if (![4, 6].includes(options.ipVersion)) {
throw new TypeError('`ipVersion` must be 4 or 6');
}
const publicIpFunctionName = options.ipVersion === 4 ? 'v4' : 'v6';
const queries = [];

@@ -56,3 +62,3 @@

(async () => {
const query = publicIp[options.version](options);
const query = publicIp[publicIpFunctionName](options);
queries.push(query);

@@ -63,3 +69,3 @@ await query;

(async () => {
const query = publicIp[options.version]({...options, onlyHttps: true});
const query = publicIp[publicIpFunctionName]({...options, onlyHttps: true});
queries.push(query);

@@ -87,3 +93,1 @@ await query;

module.exports = isOnline;
// TODO: Remove this for the next major release
module.exports.default = isOnline;
{
"name": "is-online",
"version": "8.5.1",
"version": "9.0.0",
"description": "Check if the internet connection is up",

@@ -17,3 +17,3 @@ "license": "MIT",

"engines": {
"node": ">=8"
"node": ">=10"
},

@@ -51,13 +51,18 @@ "scripts": {

"dependencies": {
"got": "^9.6.0",
"p-any": "^2.0.0",
"p-timeout": "^3.0.0",
"public-ip": "^4.0.1"
"got": "^11.8.0",
"p-any": "^3.0.0",
"p-timeout": "^3.2.0",
"public-ip": "^4.0.2"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
"tsd": "^0.13.1",
"xo": "^0.34.1"
},
"browser": "browser.js"
"browser": "browser.js",
"xo": {
"rules": {
"unicorn/prefer-optional-catch-binding": "off"
}
}
}

@@ -41,7 +41,7 @@ # is-online [![Build Status](https://travis-ci.com/sindresorhus/is-online.svg?branch=master)](https://travis-ci.com/github/sindresorhus/is-online)

##### version
##### ipVersion
Type: `string`\
Values: `'v4'` `'v6'`\
Default: `'v4'`
Type: `number`\
Values: `4 | 6`\
Default: `4`

@@ -54,5 +54,5 @@ Internet Protocol version to use. This is an advanced option that is usually not necessary to be set, but it can prove useful to specifically assert IPv6 connectivity.

- Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS
- Query `myip.opendns.com` on OpenDNS *(Node.js only)*
- Retrieve Apple's Captive Portal test page *(Node.js only)*
- Retrieve [icanhazip.com](https://github.com/major/icanhaz) (or [ipify.org](https://www.ipify.org) as fallback) via HTTPS.
- Query `myip.opendns.com` and `o-o.myaddr.l.google.com` DNS entries. *(Node.js only)*
- Retrieve Apple's Captive Portal test page (this is what iOS does). *(Node.js only)*

@@ -59,0 +59,0 @@ When the first check succeeds, the returned Promise is resolved to `true`.