UNPKG

@kitmi/utils

Version:

A JavaScript utility library for both server and browser

16 lines (11 loc) 274 B
function toBoolean(any) { const type = typeof any; if (type === 'boolean') { return any; } if (type === 'number') { return any === 1; } return type === 'string' && (any === '1' || /^true$/i.test(any)); } export default toBoolean;