mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Type definitions for is-ip (#18272)
This commit is contained in:
committed by
Wesley Wigham
parent
d7a3309b4e
commit
a07f6d8f8a
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for is-ip 2.0
|
||||
// Project: https://github.com/sindresorhus/is-ip#readme
|
||||
// Definitions by: coderslagoon <https://github.com/coderslagoon/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Check if input is IPv4 or IPv6.
|
||||
*
|
||||
* @param {input} input
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
declare function isIp(input: string): boolean;
|
||||
|
||||
declare namespace isIp {
|
||||
/**
|
||||
* Check if input is IPv4.
|
||||
*
|
||||
* @param {input} input
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function v4(input: string): boolean;
|
||||
|
||||
/**
|
||||
* Check if input is IPv6.
|
||||
*
|
||||
* @param {input} input
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function v6(input: string): boolean;
|
||||
}
|
||||
|
||||
export = isIp;
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as isIp from "is-ip";
|
||||
|
||||
isIp("nope");
|
||||
// => false
|
||||
|
||||
isIp("127.0.0.1");
|
||||
// => true
|
||||
|
||||
isIp("0.0.0.0");
|
||||
// => true
|
||||
|
||||
isIp("127.0.0.256");
|
||||
// => false
|
||||
|
||||
isIp.v4("127.0.0.1");
|
||||
// => true
|
||||
|
||||
isIp.v4("1:2:3:4:5:6:7:8");
|
||||
// => false
|
||||
|
||||
isIp.v6("1:2:3:4:5:6:7:8");
|
||||
// => true
|
||||
|
||||
isIp.v6("::");
|
||||
// => true
|
||||
|
||||
isIp.v6("127.0.0.1");
|
||||
// => false
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"is-ip-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user