main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
698 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var callBound = require('call-bound');
|
---|
4 |
|
---|
5 | var $numToStr = callBound('Number.prototype.toString');
|
---|
6 |
|
---|
7 | /** @type {import('.')} */
|
---|
8 | var tryNumberObject = function tryNumberObject(value) {
|
---|
9 | try {
|
---|
10 | $numToStr(value);
|
---|
11 | return true;
|
---|
12 | } catch (e) {
|
---|
13 | return false;
|
---|
14 | }
|
---|
15 | };
|
---|
16 | var $toString = callBound('Object.prototype.toString');
|
---|
17 | var numClass = '[object Number]';
|
---|
18 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
19 |
|
---|
20 | /** @type {import('.')} */
|
---|
21 | module.exports = function isNumberObject(value) {
|
---|
22 | if (typeof value === 'number') {
|
---|
23 | return true;
|
---|
24 | }
|
---|
25 | if (!value || typeof value !== 'object') {
|
---|
26 | return false;
|
---|
27 | }
|
---|
28 | return hasToStringTag ? tryNumberObject(value) : $toString(value) === numClass;
|
---|
29 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.