diff --git a/types/is-ip/index.d.ts b/types/is-ip/index.d.ts new file mode 100644 index 0000000000..930cb8951d --- /dev/null +++ b/types/is-ip/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for is-ip 2.0 +// Project: https://github.com/sindresorhus/is-ip#readme +// Definitions by: 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; diff --git a/types/is-ip/is-ip-tests.ts b/types/is-ip/is-ip-tests.ts new file mode 100644 index 0000000000..d062f6dde9 --- /dev/null +++ b/types/is-ip/is-ip-tests.ts @@ -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 diff --git a/types/is-ip/tsconfig.json b/types/is-ip/tsconfig.json new file mode 100644 index 0000000000..be6e5c55e0 --- /dev/null +++ b/types/is-ip/tsconfig.json @@ -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" + ] +} diff --git a/types/is-ip/tslint.json b/types/is-ip/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-ip/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }