Skip to content

xarxziux/number-detect

Repository files navigation

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

About

Thin wrapper around the chaijs/type-detect library

Resources

License

Stars

Watchers

Forks

Packages

No packages published