Files
30-seconds-of-code/node_modules/yurnalist/dist/util/conversion.js
2019-08-20 15:52:05 +02:00

16 lines
430 B
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.boolify = boolify;
exports.boolifyWithDefault = boolifyWithDefault;
const FALSY_STRINGS = new Set(['0', 'false']);
function boolify(val) {
return !FALSY_STRINGS.has(val.toString().toLowerCase());
}
function boolifyWithDefault(val, defaultResult) {
return val === '' || val === null || val === undefined ? defaultResult : boolify(val);
}