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 🙏

© 2024 – Pkg Stats / Ryan Hefner

extra-boolean.web

v1.11.0

Published

Boolean data type has two possible truth values to represent logic {web}.

Downloads

108

Readme

Boolean data type has two possible truth values to represent logic. 📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs. 📘 Wiki.

A boolean data type has two possible truth values, usually represented as true or false. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century (REF). Boolean functions can be used to perform logical operations in computer programming, such as in conditional statements, loops, and branching, to compare input values with a set of rules to determine the output.

This is a collection of common boolean functions. It includes the basic gates not, and, or, xor; their complements nand, nor, xnor; and 2 propositional logic (taught in discrete mathematics) gates imply, eq; and their complements nimply, neq. There is also a multiplexer, called select, and a true counter, called count. count can help you make custom gates, such as an alternate concept of xnor which returns true only if all inputs are the same (standard xnor returns true if even inputs are true). These gates can handle up to eight inputs.

The parse function is influenced by (boolean) package, and is quite good at translating string to boolean. It can also handle double negatives, eg. not inactive. You know the and of 2-inputs, but what of 1-input? What of 0? And what of the other gates? I answer them here.

This package is available in Node.js and Web formats. To use it on the web, simply use the extra_boolean global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

const xboolean = require('extra-boolean');
// import * as xboolean from "extra-boolean";
// import * as xboolean from "https://unpkg.com/extra-boolean/index.mjs"; (deno)

xboolean.parse('1');
xboolean.parse('not off');
xboolean.parse('truthy');
// → true

xboolean.parse('not true');
xboolean.parse('inactive');
xboolean.parse('disabled');
// → false

xboolean.imply(true, false);
// → false

xboolean.eq(false, false);
// → true

xboolean.xor(true, true, true);
// → true

xboolean.select(1, true, false, true);
// → false                ^

xboolean.count(true, false, true);
// → 2         ^            ^

Index

| Property | Description | | ---- | ---- | | is | Check if a value is boolean. | | parse | Convert a string to boolean. | | | | | not | Check if a boolean is false. | | imply | Check if antecedent ⇒ consequent. | | nimply | Check if antecedent ⇏ consequent. | | eq | Check if antecedent ⇔ consequent. | | neq | Check if antecedent ⇎ consequent. | | | | | and | Check if all booleans are true. | | nand | Check if any boolean is false. | | or | Check if any boolean is true. | | nor | Check if all booleans are false. | | xor | Check if odd number of booleans are true. | | xnor | Check if even number of booleans are true. | | | | | count | Count number of true booleans. | | select | Check if iᵗʰ boolean is true. |

References

ORG DOI Coverage Status Test Coverage Maintainability