ignite-cli
Version:
Infinite Red's hottest boilerplate for React Native.
30 lines • 1.03 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.boolFlag = exports.bool = void 0;
/**
* Utility for converting 'true' and 'false' strings to booleans.
*
* Both `Boolean('true')` and `Boolean('false')` return `true`, because any string is a truthy value.
* `!!'true'` and `!!'false'` also return `true`, for the same reason.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
*
* @param value The value to check.
* @returns `true` for 'true', `false` for 'false', `Boolean` result otherwise.
*/
function bool(value) {
if (value === "false")
return false;
return Boolean(value);
}
exports.bool = bool;
/**
* Utility for converting 'true' and 'false' strings to booleans,
* while preserving `undefined` values as `undefined` instead of `false`.
*/
function boolFlag(option) {
if (option === undefined)
return undefined;
return bool(option);
}
exports.boolFlag = boolFlag;
//# sourceMappingURL=flag.js.map
;