is-number-object
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -0,1 +1,5 @@ | ||
1.0.3 / 2015-01-29 | ||
================= | ||
* If @@toStringTag is not present, use the old-school Object#toString test. | ||
1.0.2 / 2015-01-29 | ||
@@ -2,0 +6,0 @@ ================= |
'use strict'; | ||
var toStr = Number.prototype.toString; | ||
var numToStr = Number.prototype.toString; | ||
var tryNumberObject = function tryNumberObject(value) { | ||
try { | ||
toStr.call(value); | ||
numToStr.call(value); | ||
return true; | ||
@@ -12,2 +12,5 @@ } catch (e) { | ||
}; | ||
var toStr = Object.prototype.toString; | ||
var numClass = '[object Number]'; | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
@@ -17,3 +20,3 @@ module.exports = function isNumberObject(value) { | ||
if (typeof value !== 'object') { return false; } | ||
return tryNumberObject(value); | ||
return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass; | ||
}; |
{ | ||
"name": "is-number-object", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": "Jordan Harband", | ||
@@ -5,0 +5,0 @@ "description": "Is this value a JS Number object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17815
90