@tobius/istruthy

0.2.8 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i @tobius/istruthy

Weekly Downloads

4

Version

0.2.8

License

MIT

Unpacked Size

3.99 kB

Total Files

6

Last publish

Collaborators

  • tobius