@ts-simple/str-2-bool
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i @ts-simple/str-2-bool

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.43 kB

Total Files

9

Last publish

Collaborators

  • arturo.silvelo