-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
- Loading branch information
1 parent
a8c9c56
commit 32c4266
Showing
4 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
declare namespace internalIp { | ||
/** | ||
* @returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(await internalIp.v6()); | ||
* //=> 'fe80::1' | ||
*/ | ||
export function v6(): Promise<string>; | ||
export namespace v6 { | ||
/** | ||
* @returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(internalIp.v6.sync()); | ||
* //=> 'fe80::1' | ||
*/ | ||
function sync(): string; | ||
} | ||
|
||
/** | ||
* @returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(await internalIp.v4()) | ||
* //=> '10.0.0.79' | ||
*/ | ||
export function v4(): Promise<string>; | ||
export namespace v4 { | ||
/** | ||
* @returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned. | ||
* | ||
* @example | ||
* | ||
* console.log(internalIp.v4.sync()) | ||
* //=> '10.0.0.79' | ||
*/ | ||
function sync(): string; | ||
} | ||
} | ||
|
||
export default internalIp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {expectType} from 'tsd-check'; | ||
import internalIp from '.'; | ||
|
||
expectType<string>(await internalIp.v4()); | ||
expectType<string>(await internalIp.v6()); | ||
|
||
expectType<string>(internalIp.v4.sync()); | ||
expectType<string>(internalIp.v6.sync()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters