source: imaps-frontend/node_modules/is-boolean-object/index.js

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
RevLine 
[d565449]1'use strict';
2
3var callBound = require('call-bind/callBound');
4var $boolToStr = callBound('Boolean.prototype.toString');
5var $toString = callBound('Object.prototype.toString');
6
7var tryBooleanObject = function booleanBrandCheck(value) {
8 try {
9 $boolToStr(value);
10 return true;
11 } catch (e) {
12 return false;
13 }
14};
15var boolClass = '[object Boolean]';
16var hasToStringTag = require('has-tostringtag/shams')();
17
18module.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.