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

boolean-ts

v1.0.2

Published

Compile time support for runtime logic operations in Typescript

Downloads

1

Readme

boolean-ts

Compile time support for runtime logic operations in Typescript

Coming soon!

Non-binary arguments

Currently these functions are binary (excluding b.not(boolean)), meaning they only take two inputs. We'll be looking to extends these to take multiple booleans as arguments for the following functions:

  • and
  • nan
  • or
  • nor

Pipeable

A functional programming API that supports piping is a great feature. We'll be adding overloads to support these soon.

If a function requries 2 or more arguments, the first will be partially applied and returns a function that takes the rest.

Installation

// yarn
yarn add boolean-ts

// npm
npm install boolean-ts

Example

import * as b from "boolean-ts";

const value1 = b.not(true); //type is false

const value2 = b.and(true, true); // type is true
const value3 = b.and(true, false); // type is false
const value4 = b.and(false, false); // type is false

const value4 = b.xnor(true, false); // type is true

Theory

Based off information from this website on basic logic gates, we'll document some useful concepts here.

Truth Tables

A truth table is a table that visually demonstrate how the logic gate should work. We'll focus on binary functions. There is a truth table for each operation: and, or, nand, nor, xor, xnor.

And

Outputs true when all inputs are true.

| A | B | Result | | --- | --- | ------ | | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |

Or

Outputs true when any input is true.

| A | B | Result | | :-: | :-: | :----- | | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 1 |

Nand

Opposite of And. Ouputs true when both outputs are not true.

| A | B | Result | | :-: | :-: | :----- | | 0 | 0 | 1 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 0 |

Nor

Opposite of Or. Outputs true when both inputs are false

| A | B | Result | | :-: | :-: | :----- | | 0 | 0 | 1 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 0 |

Xor

Ouputs true when inputs are mismatched true/false.

| A | B | Result | | :-: | :-: | :----- | | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 0 |

Xnor

Ouputs true when both inputs are true or both inputs are false.

| A | B | Result | | :-: | :-: | :----- | | 0 | 0 | 1 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |