Frontend/25_01_07/mai/node_modules/is-number-object/index.js

30 lines
698 B
JavaScript
Raw Permalink Normal View History

2025-01-28 10:38:27 +00:00
'use strict';
var callBound = require('call-bound');
var $numToStr = callBound('Number.prototype.toString');
/** @type {import('.')} */
var tryNumberObject = function tryNumberObject(value) {
try {
$numToStr(value);
return true;
} catch (e) {
return false;
}
};
var $toString = callBound('Object.prototype.toString');
var numClass = '[object Number]';
var hasToStringTag = require('has-tostringtag/shams')();
/** @type {import('.')} */
module.exports = function isNumberObject(value) {
if (typeof value === 'number') {
return true;
}
if (!value || typeof value !== 'object') {
return false;
}
return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass;
};