Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boolean-ts

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boolean-ts

Compile time support for runtime logic operations in Typescript

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

ABResult
000
010
100
111

Or

Outputs true when any input is true.

ABResult
000
011
101
111
Nand

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

ABResult
001
011
101
110
Nor

Opposite of Or. Outputs true when both inputs are false

ABResult
001
010
100
110
Xor

Ouputs true when inputs are mismatched true/false.

ABResult
000
011
101
110
Xnor

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

ABResult
001
010
100
111

FAQs

Package last updated on 12 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc