You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
567 B
25 lines
567 B
2 years ago
|
'use strict';
|
||
|
|
||
|
var numToStr = Number.prototype.toString;
|
||
|
var tryNumberObject = function tryNumberObject(value) {
|
||
|
try {
|
||
|
numToStr.call(value);
|
||
|
return true;
|
||
|
} catch (e) {
|
||
|
return false;
|
||
|
}
|
||
|
};
|
||
|
var toStr = Object.prototype.toString;
|
||
|
var numClass = '[object Number]';
|
||
|
var hasToStringTag = require('has-tostringtag/shams')();
|
||
|
|
||
|
module.exports = function isNumberObject(value) {
|
||
|
if (typeof value === 'number') {
|
||
|
return true;
|
||
|
}
|
||
|
if (typeof value !== 'object') {
|
||
|
return false;
|
||
|
}
|
||
|
return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass;
|
||
|
};
|