Changeset 79a0317 for imaps-frontend/node_modules/is-number-object/index.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/is-number-object/index.js
r0c6b92a r79a0317 1 1 'use strict'; 2 2 3 var numToStr = Number.prototype.toString; 3 var callBound = require('call-bound'); 4 5 var $numToStr = callBound('Number.prototype.toString'); 6 7 /** @type {import('.')} */ 4 8 var tryNumberObject = function tryNumberObject(value) { 5 9 try { 6 numToStr.call(value);10 $numToStr(value); 7 11 return true; 8 12 } catch (e) { … … 10 14 } 11 15 }; 12 var toStr = Object.prototype.toString;16 var $toString = callBound('Object.prototype.toString'); 13 17 var numClass = '[object Number]'; 14 18 var hasToStringTag = require('has-tostringtag/shams')(); 15 19 20 /** @type {import('.')} */ 16 21 module.exports = function isNumberObject(value) { 17 22 if (typeof value === 'number') { 18 23 return true; 19 24 } 20 if ( typeof value !== 'object') {25 if (!value || typeof value !== 'object') { 21 26 return false; 22 27 } 23 return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass;28 return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass; 24 29 };
Note:
See TracChangeset
for help on using the changeset viewer.