[float-regex] add definition (#26073)

This commit is contained in:
Anjun Wang
2018-05-30 06:46:43 +08:00
committed by Mohamed Hegazy
parent 9004146f8e
commit 09bf36d49d
4 changed files with 53 additions and 0 deletions

View File

@@ -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);

17
types/float-regex/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for float-regex 1.0
// Project: https://github.com/substack/float-regex
// Definitions by: Anjun Wang <https://github.com/wanganjun>
// 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;

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }