1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 10:51:56 +00:00
musix-oss/node_modules/is-number-object/index.js

25 lines
603 B
JavaScript
Raw Normal View History

2020-03-03 20:30:50 +00:00
'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 = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
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;
};