@ts-simple/str-2-bool
v1.0.0
Published
Convert string value to boolean value
Downloads
9
Maintainers
Readme
str-2-bool
Simple function to convert string (true, false) to boolean value.
API
- str2Bool(value:string, strict: boolean = true) => boolean | null;
Usage
import { str2Bool } from '@ts-simple/str-2-bool'
console.log(str2Bool("true"));
/* Expected result is true*/
console.log(str2Bool("truE"));
/* Expected result is true*/
console.log(str2Bool("false"));
/* Expected result is false*/
console.log(str2Bool("falsE"));
/* Expected result is false*/
console.log(str2Bool("randomValue"));
/* Expected result is null*/
console.log(str2Bool("randomValue", false));
/* Expected result is false*/