Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
78ca387
commit 14a9c14
Showing
9 changed files
with
172 additions
and
170 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
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 @@ | ||
export * from './index.js'; |
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 |
---|---|---|
@@ -1,62 +1,51 @@ | ||
interface 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, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(internalIp.v6.sync()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
sync: () => string | undefined; | ||
|
||
/** | ||
@returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(await internalIp.v6()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
(): Promise<string | undefined>; | ||
} | ||
|
||
interface 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, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(internalIp.v4.sync()) | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
sync: () => string | undefined; | ||
|
||
/** | ||
@returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import internalIp = require('internal-ip'); | ||
console.log(await internalIp.v4()) | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
(): Promise<string | undefined>; | ||
} | ||
|
||
declare const internalIp: { | ||
v6: v6; | ||
v4: v4; | ||
}; | ||
|
||
export = 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, `undefined` will be returned. | ||
@example | ||
``` | ||
import {internalIpV6} from 'internal-ip'; | ||
console.log(await internalIpV6()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
export function internalIpV6(): Promise<string | undefined>; | ||
|
||
/** | ||
@returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import {internalIpV4} from 'internal-ip'; | ||
console.log(await internalIpV4()); | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
export function internalIpV4(): Promise<string | undefined>; | ||
|
||
/** | ||
@returns The IPv6 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import {internalIpV6Sync} from 'internal-ip'; | ||
console.log(internalIpV6Sync()); | ||
//=> 'fe80::1' | ||
``` | ||
*/ | ||
export function internalIpV6Sync(): string | undefined; | ||
|
||
/** | ||
@returns The IPv4 address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned. | ||
@example | ||
``` | ||
import {internalIpV4Sync} from 'internal-ip'; | ||
console.log(internalIpV4Sync()); | ||
//=> '10.0.0.79' | ||
``` | ||
*/ | ||
export function internalIpV4Sync(): string | undefined; |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import {expectType} from 'tsd'; | ||
import internalIp = require('.'); | ||
import {internalIpV4, internalIpV6, internalIpV4Sync, internalIpV6Sync} from './index.js'; | ||
|
||
expectType<string | undefined>(await internalIp.v4()); | ||
expectType<string | undefined>(await internalIp.v6()); | ||
expectType<string | undefined>(await internalIpV4()); | ||
expectType<string | undefined>(await internalIpV6()); | ||
|
||
expectType<string | undefined>(internalIp.v4.sync()); | ||
expectType<string | undefined>(internalIp.v6.sync()); | ||
expectType<string | undefined>(internalIpV4Sync()); | ||
expectType<string | undefined>(internalIpV6Sync()); |
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
Oops, something went wrong.