
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Compile time support for runtime logic operations in Typescript
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:
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.
// yarn
yarn add boolean-ts
// npm
npm install boolean-ts
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
Based off information from this website on basic logic gates, we'll document some useful concepts here.
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
.
Outputs true when all inputs are true.
A | B | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Outputs true when any input is true.
A | B | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
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 |
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 |
Ouputs true when inputs are mismatched true/false.
A | B | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
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 |
FAQs
Compile time support for runtime logic operations in Typescript
The npm package boolean-ts receives a total of 0 weekly downloads. As such, boolean-ts popularity was classified as not popular.
We found that boolean-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.