From cd116a2d2987acf2f8c5c7f0156a2f8f7ef8f7e7 Mon Sep 17 00:00:00 2001 From: Daniel Perez Alvarez Date: Tue, 17 Jan 2017 21:08:15 +0100 Subject: [PATCH] Add types for ip-regex 2.0.0 (#14069) --- ip-regex/index.d.ts | 12 ++++++++++++ ip-regex/ip-regex-tests.ts | 7 +++++++ ip-regex/tsconfig.json | 20 ++++++++++++++++++++ ip-regex/tslint.json | 1 + 4 files changed, 40 insertions(+) create mode 100644 ip-regex/index.d.ts create mode 100644 ip-regex/ip-regex-tests.ts create mode 100644 ip-regex/tsconfig.json create mode 100644 ip-regex/tslint.json 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" }