npm.io
0.4.0 • Published 5 years ago

number-detect

Licence
MIT
Version
0.4.0
Deps
1
Size
3 kB
Vulns
0
Weekly
0

NUMBER-DETECT

This library is a thin wrapper around the type-detect library, and began life as a rejected pull request for that library.

The library exposes a single function - numberDetect - which follows this logic:

  1. If the typeof the parameter passed is not equal to 'object' or 'number' return the typeof.
  2. If the typeof is 'object' and that object is null, return 'null', otherwise pass it to the type-detect library.
  3. If the typeof is 'number', sub-divide that type into 'NaN', 'Infinity', and 'number'.

The type-detect library only deals with 'object' typeofs and simply returns everything else, but for my uses, typeof 'number' is not useful given that typeof NaN, Infinity, and -Infinity all return 'number'. This library aims to fix that by returning a more meaningful result.

Installation

npm install --save number-detect

Codacy Badge

Keywords