Merge pull request #32042 from BendingBender/is-online

[is-online] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-15 17:57:43 -08:00
committed by GitHub
4 changed files with 64 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for is-online 8.0
// Project: https://github.com/sindresorhus/is-online#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = isOnline;
/**
* 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)
*
* When the first check succeeds, the returned Promise is resolved to `true`.
*/
declare function isOnline(options?: isOnline.Options): Promise<boolean>;
declare namespace isOnline {
interface Options {
/**
* Milliseconds to wait for a server to respond.
* @default 5000
*/
timeout?: number;
/**
* 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.
* @default 'v4'
*/
version?: 'v4' | 'v6';
}
}
+6
View File
@@ -0,0 +1,6 @@
import isOnline = require('is-online');
isOnline(); // $ExpectType Promise<boolean>
isOnline({ timeout: 10 }); // $ExpectType Promise<boolean>
isOnline({ version: 'v4' }); // $ExpectType Promise<boolean>
isOnline({ version: 'v6' }); // $ExpectType Promise<boolean>
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"is-online-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }