Skip to content
/ is-truish Public

Converts a somewhat true-ish expression to the equivalent boolean value.

License

Notifications You must be signed in to change notification settings

cgrs/is-truish

Repository files navigation

is-truish

Converts a somewhat true-ish expression to the equivalent boolean value.

Installation

npm i is-truish

Usage

import isTruish from 'is-truish';

const value = "yes";

if (isTruish(value)) {
  console.log("truish!");
}

Equivalence table

Expression Boolean value
1 (number) true
"1" (string) true
"yes" true
true (boolean) true 
"true" (string) true 

Everything else is false ("no", false, "false", 0, "0", NaN...).

About

Converts a somewhat true-ish expression to the equivalent boolean value.

Topics

Resources

License

Stars

Watchers

Forks