main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
697 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var callBound = require('call-bind/callBound');
|
---|
| 4 | var $boolToStr = callBound('Boolean.prototype.toString');
|
---|
| 5 | var $toString = callBound('Object.prototype.toString');
|
---|
| 6 |
|
---|
| 7 | var tryBooleanObject = function booleanBrandCheck(value) {
|
---|
| 8 | try {
|
---|
| 9 | $boolToStr(value);
|
---|
| 10 | return true;
|
---|
| 11 | } catch (e) {
|
---|
| 12 | return false;
|
---|
| 13 | }
|
---|
| 14 | };
|
---|
| 15 | var boolClass = '[object Boolean]';
|
---|
| 16 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
| 17 |
|
---|
| 18 | module.exports = function isBoolean(value) {
|
---|
| 19 | if (typeof value === 'boolean') {
|
---|
| 20 | return true;
|
---|
| 21 | }
|
---|
| 22 | if (value === null || typeof value !== 'object') {
|
---|
| 23 | return false;
|
---|
| 24 | }
|
---|
| 25 | return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass;
|
---|
| 26 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.