MES手机端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
707 B

  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $numToStr = callBound('Number.prototype.toString');
  4. /** @type {import('.')} */
  5. var tryNumberObject = function tryNumberObject(value) {
  6. try {
  7. $numToStr(value);
  8. return true;
  9. } catch (e) {
  10. return false;
  11. }
  12. };
  13. var $toString = callBound('Object.prototype.toString');
  14. var numClass = '[object Number]';
  15. var hasToStringTag = require('has-tostringtag/shams')();
  16. /** @type {import('.')} */
  17. module.exports = function isNumberObject(value) {
  18. if (typeof value === 'number') {
  19. return true;
  20. }
  21. if (!value || typeof value !== 'object') {
  22. return false;
  23. }
  24. return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass;
  25. };