feat(fast-isnumeric): new type definition v1.1 (#43659)

Small helper function From Plotly project:
- definition file
- tests

https://github.com/plotly/fast-isnumeric#api

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-04-07 17:17:55 +02:00 committed by GitHub
parent b1896394f3
commit 51269623f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,6 @@
import isNumeric = require('fast-isnumeric');
// tslint:disable-next-line: no-construct
isNumeric(new String('1')); // $ExpectType boolean
isNumeric(1); // $ExpectType boolean
isNumeric('1'); // $ExpectType boolean

16
types/fast-isnumeric/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
// Type definitions for fast-isnumeric 1.1
// Project: https://github.com/plotly/fast-isnumeric#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* The fast way to check if a JS object is numeric
* Inspired by is-number <https://github.com/jonschlinkert/is-number>
* but significantly simplified and sped up by ignoring number and string constructors
* ie these return false:
* new Number(1)
* new String('1')
*/
declare function isNumeric(n: any): boolean;
export = isNumeric;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fast-isnumeric-tests.ts"
]
}

View File

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