istrue
v1.0.1
Published
A useful function to check if a javascript object evaluates to `true`
Downloads
8
Maintainers
Readme
isTrue
A useful function to check if a javascript object evaluates to true
Getting started
Bower:
bower install isTrue
npm:
npm install istrue --save
Or clone from github:
git clone https://github.com/codeocelot/istrue.git
.
node:
require("./path/to/repo/main.js");
html embedded js:
<script src="./path/to/main.js' type="text/javascript">
run tests (mocha,assert):
mocha test.js
How to use
"does this eval to true".isTrue() === true
"".isTrue() === false
Numbers, Arrays & Objects too! (don't forget the paratheses, otherwise js thinks it's a decimal!)
(0).isTrue() === false
(1).isTrue() === true
({}).isTrue() === true // js likes parans around obj/array declarations
([]).isTrue() === true
Future
I can't think of a future for extentending this simple function. Share your thoughts if you have ideas!