diff --git a/index.js b/index.js index 6f23b06..69864eb 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,17 @@ 'use strict'; -var boolToStr = Boolean.prototype.toString; +var callBound = require('call-bind/callBound'); +var $boolToStr = callBound('Boolean.prototype.toString'); +var $toString = callBound('Object.prototype.toString'); var tryBooleanObject = function booleanBrandCheck(value) { try { - boolToStr.call(value); + $boolToStr(value); return true; } catch (e) { return false; } }; -var toStr = Object.prototype.toString; var boolClass = '[object Boolean]'; var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; @@ -21,5 +22,5 @@ module.exports = function isBoolean(value) { if (value === null || typeof value !== 'object') { return false; } - return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : toStr.call(value) === boolClass; + return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass; }; diff --git a/package.json b/package.json index 31be296..5504f6c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,9 @@ "false", "is-boolean" ], - "dependencies": {}, + "dependencies": { + "call-bind": "^1.0.0" + }, "devDependencies": { "@ljharb/eslint-config": "^17.3.0", "aud": "^1.1.3",