npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

betterboolean

v1.0.0

Published

A "better" boolean, which can be negative. If you wanted that for some reason.

Downloads

19

Readme

BetterBoolean

A "better" boolean, which can be negative. If you wanted that for some reason.

Creating a BetterBoolean

var bool = new BetterBoolean([init]); where init is the optional initial value.

BetterBooleans can be initialized with booleans, strings, numbers, and other BetterBooleans. Regular booleans will not set a sign other than positive.

Reading the value

You can use your BetterBoolean anywhere in your code as you wish, and it will automatically be converted into a number that you can compare.

true becomes 1, false becomes 0, -true becomes -1, and -false becomes -0.

Converting to a string

bool.toString(); will return a string along the lines of true, false, -true, or -false depending on the state of the BetterBoolean.

Converting to an integer manually

Should you need to convert your BetterBoolean into an integer similiar to that described above, you can use bool.toInt(); to get it in integer form.

Comparing the value

bool.equals(value) where value is a boolean, string, number, or BetterBoolean. It simply checks if the BetterBoolean and value are equal.

Updating the value

bool.set(value); where value is the required updated value.

BetterBooleans can be updated with booleans, strings, numbers, and other BetterBooleans in a similar fashion as creating a new one. Regular booleans will not set a sign other than positive.

Changing the sign

bool.setSign(value); where value is the required updated sign.

The sign may be set using booleans, strings, numbers, and other BetterBooleans. -true will be treated as false, and -false will be treated as true.

Booleans

bool.setSign(true); will set the sign to be negative, and bool.setSign(false); will set it to be positive.

Strings

value may be "true", "negative", "false", and "positive".

"true" and "negative" will set the sign to be negative, and "false" and "positive" will set the sign to be positive.

Numbers

value may be 1 or -1, with 1 setting the sign to be positive and -1 setting the sign to be negative.

BetterBooleans

value will be treated like a boolean, with -true being false and -false being true.

Changing the state

bool.setState(value); where value is the required updated sign.

The sign may be set using booleans, strings, numbers, and other BetterBooleans. -true will be treated as false, and -false will be treated as true.

Booleans

bool.setState(true); will set the state to be true, and bool.setState(false); will set it to be false.

Strings

value may be "true" or "false" and will be treated like booleans.

Numbers

value may be 0 or 1, with 1 setting the state to be true and 0 setting the state to be false.

BetterBooleans

value will be treated like a boolean, with -true being false and -false being true.