diff --git a/types/float-regex/float-regex-tests.ts b/types/float-regex/float-regex-tests.ts new file mode 100644 index 0000000000..d4a0f36633 --- /dev/null +++ b/types/float-regex/float-regex-tests.ts @@ -0,0 +1,12 @@ +import regexp = require('float-regex'); + +const foo: RegExp = regexp; + +const anchor = RegExp(`^${regexp.source}$`); +anchor.test('1.23e24'); // true +anchor.test('1.23e24.55'); // false + +const freg = regexp.source; +const capture = RegExp(`\\b(${freg})\\b`, 'g'); +const str = '1.2 555 beep boop 4.2.1.5 66.2e99 22.54e23 qrs2'; +str.match(capture); diff --git a/types/float-regex/index.d.ts b/types/float-regex/index.d.ts new file mode 100644 index 0000000000..36d2ff7527 --- /dev/null +++ b/types/float-regex/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for float-regex 1.0 +// Project: https://github.com/substack/float-regex +// Definitions by: Anjun Wang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * regular expression for real floating point values in javascript notation: + * ``` + * /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/ + * ``` + * + * does not match: + * * +/- Infinity + * * NaN + */ +declare const regexp: RegExp; +export = regexp; diff --git a/types/float-regex/tsconfig.json b/types/float-regex/tsconfig.json new file mode 100644 index 0000000000..61ea825706 --- /dev/null +++ b/types/float-regex/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "float-regex-tests.ts" + ] +} \ No newline at end of file diff --git a/types/float-regex/tslint.json b/types/float-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/float-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }