UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

29 lines (22 loc) 577 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; /** * Convert a boolean from a string or boolean, return default value in case of null or undefined */ var toBoolean = function toBoolean(value, defaultValue) { if (value === null || value === undefined) { return defaultValue; } const valueAsString = String(value).trim().toLowerCase(); if (valueAsString === 'true') { return true; } if (valueAsString === 'false') { return false; } return defaultValue; }; exports.default = toBoolean;