Permalink
Browse files

Merge pull request #14 from component/NaN

Checking for NaN, fixes #12
  • Loading branch information...
2 parents 639a20c + 8f330eb commit 5722c0d4c0e537fff2012cc767dfa442f5af6194 @dominicbarnes dominicbarnes committed Jan 9, 2014
Showing with 8 additions and 0 deletions.
  1. +1 −0 index.js
  2. +7 −0 test/tests.js
View
@@ -23,6 +23,7 @@ module.exports = function(val){
if (val === null) return 'null';
if (val === undefined) return 'undefined';
+ if (val !== val) return 'NaN';
if (val && val.nodeType === 1) return 'element';
return typeof val.valueOf();
View
@@ -10,7 +10,14 @@ describe('type', function(){
it('should match numbers', function(){
assert('number' === type(12));
+ assert('number' === type(1.0));
+ assert('number' === type(-5));
assert('number' === type(new Number(123)));
+ assert('number' === type(Infinity));
+ });
+
+ it('should match NaN', function () {
+ assert('NaN' === type(NaN));
});
it('should match strings', function(){

0 comments on commit 5722c0d

Please sign in to comment.