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

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