0.2.8 • Published 2 years ago

@tobius/istruthy v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

isTruthy

Determine if a given value is "truthy" (likely to represent boolean true).

Install

[~] npm i @tobius/istruthy

Supported by Node.js version 4, 6, 8, 10, 12, 14, and 16.

Usage

const isTruthy = require('isTruthy');

// true
console.log([
	isTruthy('1'),
	isTruthy('1.0'),
	isTruthy('active'),
	isTruthy('on'),
	isTruthy('true'),
	isTruthy(1),
	isTruthy(1.0),
	isTruthy(true),
]);

// false
console.log([
	isTruthy('-1'),
	isTruthy('-1.5'),
	isTruthy('-100'),
	isTruthy('-100.5'),
	isTruthy('0'),
	isTruthy('0.0'),
	isTruthy('1.5'),
	isTruthy('100'),
	isTruthy('100.5'),
	isTruthy('Infinity'),
	isTruthy('NaN'),
	isTruthy('false'),
	isTruthy('inactive'),
	isTruthy('null'),
	isTruthy('off'),
	isTruthy('undefined'),
	isTruthy(-1),
	isTruthy(-1.5),
	isTruthy(-100),
	isTruthy(-100.5),
	isTruthy(0),
	isTruthy(0.0),
	isTruthy(1.5),
	isTruthy(100),
	isTruthy(100.5),
	isTruthy(Infinity),
	isTruthy(NaN),
	isTruthy(false),
	isTruthy(null),
	isTruthy(undefined),
]);

License

This software library is licensed under the MIT License.

0.2.8

2 years ago

0.2.7

3 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago