|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
711 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var callBound = require('call-bound');
|
|---|
| 4 | var $boolToStr = callBound('Boolean.prototype.toString');
|
|---|
| 5 | var $toString = callBound('Object.prototype.toString');
|
|---|
| 6 |
|
|---|
| 7 | /** @type {import('.')} */
|
|---|
| 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 |
|
|---|
| 19 | /** @type {import('.')} */
|
|---|
| 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 ? tryBooleanObject(value) : $toString(value) === boolClass;
|
|---|
| 28 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.