1.0.0 • Published 1 year ago

@ts-simple/str-2-bool v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

str-2-bool

Build Status Coverage Status

npm npm bundle size (scoped version) NPM

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*/