is-truish

1.0.1 • Public • Published

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...).

Package Sidebar

Install

npm i is-truish

Weekly Downloads

1

Version

1.0.1

License

GPL-3.0

Unpacked Size

37.1 kB

Total Files

5

Last publish

Collaborators

  • recio