qc-to_bool
A simple JavaScript utility to convert various values to a boolean.
Installation
npm install --save qc-to_bool
Example Usage
; ; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `true`; // `false`; // `'other'` (input); // `false`; // `false`; // `{}` (input); // `false`; // `true`; // `null`; // `false`; // `true`; // `false`; // `true`; // `null`; // `null` // Use different converter:; // `''` (input)// Based on JavaScript truthiness:toBool;; // `false`; // `true` // Based on Japanese language:let { let coercedInput output; if input !== undefined && input !== null if typeof inputvalueOf == 'function' coercedInput = input; if coercedInput && typeof coercedInputtoString == 'function' coercedInput = coercedInput; output = converterlutcoercedInput; return output;};converterlut = h: true hai: true i: false iie: false;toBool;; // `true`; // `false` // Set back to default converter:toBool;