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:
742 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
[79a0317] | 3 | var callBound = require('call-bound');
|
---|
[d565449] | 4 | var $boolToStr = callBound('Boolean.prototype.toString');
|
---|
| 5 | var $toString = callBound('Object.prototype.toString');
|
---|
| 6 |
|
---|
[79a0317] | 7 | /** @type {import('.')} */
|
---|
[d565449] | 8 | var tryBooleanObject = function booleanBrandCheck(value) {
|
---|
| 9 | try {
|
---|
| 10 | $boolToStr(value);
|
---|
| 11 | return true;
|
---|
| 12 | } catch (e) {
|
---|
| 13 | return false;
|
---|
| 14 | }
|
---|
| 15 | };
|
---|
| 16 | var boolClass = '[object Boolean]';
|
---|
| 17 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
| 18 |
|
---|
[79a0317] | 19 | /** @type {import('.')} */
|
---|
[d565449] | 20 | module.exports = function isBoolean(value) {
|
---|
| 21 | if (typeof value === 'boolean') {
|
---|
| 22 | return true;
|
---|
| 23 | }
|
---|
| 24 | if (value === null || typeof value !== 'object') {
|
---|
| 25 | return false;
|
---|
| 26 | }
|
---|
| 27 | return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass;
|
---|
| 28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.