diff --git a/ip-regex/index.d.ts b/ip-regex/index.d.ts new file mode 100644 index 0000000000..c26cbaab3b --- /dev/null +++ b/ip-regex/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for ip-regex 2.0 +// Project: https://github.com/sindresorhus/ip-regex +// Definitions by: Daniel Perez Alvarez +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** Regular expression for matching IP addresses (IPv4 & IPv6). */ +declare function ipRegex(options?: { + /** Only match an exact string. Useful with RegExp#test to check if a string is an IP address. */ + exact?: boolean; +}): RegExp; + +export = ipRegex; diff --git a/ip-regex/ip-regex-tests.ts b/ip-regex/ip-regex-tests.ts new file mode 100644 index 0000000000..dcaa72c72d --- /dev/null +++ b/ip-regex/ip-regex-tests.ts @@ -0,0 +1,7 @@ +import ipRegex = require('ip-regex'); + +ipRegex().test('unicorn 192.168.0.1'); + +ipRegex({exact: true}).test('unicorn 192.168.0.1'); + +'unicorn 192.168.0.1 cake 1:2:3:4:5:6:7:8 rainbow'.match(ipRegex()); diff --git a/ip-regex/tsconfig.json b/ip-regex/tsconfig.json new file mode 100644 index 0000000000..5cb66f8d50 --- /dev/null +++ b/ip-regex/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ip-regex-tests.ts" + ] +} diff --git a/ip-regex/tslint.json b/ip-regex/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/ip-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }