Type definitions for is-ip (#18272)

This commit is contained in:
coderslagoon
2017-07-21 10:01:15 -07:00
committed by Wesley Wigham
parent d7a3309b4e
commit a07f6d8f8a
4 changed files with 86 additions and 0 deletions
+35
View File
@@ -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;
+28
View File
@@ -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
+22
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }