From 51269623f01c60383dbd436656527cae34cee74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Tue, 7 Apr 2020 17:17:55 +0200 Subject: [PATCH] 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! --- types/fast-isnumeric/fast-isnumeric-tests.ts | 6 +++++ types/fast-isnumeric/index.d.ts | 16 ++++++++++++++ types/fast-isnumeric/tsconfig.json | 23 ++++++++++++++++++++ types/fast-isnumeric/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 types/fast-isnumeric/fast-isnumeric-tests.ts create mode 100644 types/fast-isnumeric/index.d.ts create mode 100644 types/fast-isnumeric/tsconfig.json create mode 100644 types/fast-isnumeric/tslint.json diff --git a/types/fast-isnumeric/fast-isnumeric-tests.ts b/types/fast-isnumeric/fast-isnumeric-tests.ts new file mode 100644 index 0000000000..155c0ac93d --- /dev/null +++ b/types/fast-isnumeric/fast-isnumeric-tests.ts @@ -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 diff --git a/types/fast-isnumeric/index.d.ts b/types/fast-isnumeric/index.d.ts new file mode 100644 index 0000000000..94bb79c89c --- /dev/null +++ b/types/fast-isnumeric/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * The fast way to check if a JS object is numeric + * Inspired by 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; diff --git a/types/fast-isnumeric/tsconfig.json b/types/fast-isnumeric/tsconfig.json new file mode 100644 index 0000000000..21960fbc87 --- /dev/null +++ b/types/fast-isnumeric/tsconfig.json @@ -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" + ] +} diff --git a/types/fast-isnumeric/tslint.json b/types/fast-isnumeric/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fast-isnumeric/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }