Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14 from component/NaN

Checking for NaN, fixes #12
  • Loading branch information...
commit 5722c0d4c0e537fff2012cc767dfa442f5af6194 2 parents 639a20c + 8f330eb
@dominicbarnes dominicbarnes authored
Showing with 8 additions and 0 deletions.
  1. +1 −0  index.js
  2. +7 −0 test/tests.js
View
1  index.js
@@ -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
7 test/tests.js
@@ -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(){
Please sign in to comment.
Something went wrong with that request. Please try again.