New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

logiqual

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logiqual

A lightweight library for comparing boolean functions and generating truth tables.

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

⚖️ logiqual

A lightweight library for comparing boolean functions and generating truth tables. This tool allows you to validate the equality of logical expressions efficiently and effectively.

🚀 Features

  • Functions comparison – determine if two boolean functions produce the same outputs for all possible inputs.
  • Truth table generation – create detailed truth tables for any variadic boolean function.
  • Detailed mismatch reporting – provides specific input combinations where functions differ.

🛠️ Installation

npm install logiqual

📖 Usage

Comparing Functions

import { compareFunctions } from 'logiqual';

const result = compareFunctions(
  (x, y) => x && y,
  (x, y) => x || y
);

console.log(result.isEqual); // false
console.log(result.differences); // Detailed differences

Generating a Truth Table

import { generateTruthTable } from 'logiqual';

const table = generateTruthTable((a, b) => a && b);
console.table(table);

Command Line Interface (CLI)

You can also use it via the command line:

npx logiqual '(x, y) => x && y' '(x, y) => x || y'
# false
# [
#   [
#     { x: false, y: true, result: false },
#     { x: false, y: true, result: true }
#   ],
#   [
#     { x: true, y: false, result: false },
#     { x: true, y: false, result: true }
#   ]
# ]

🔧 API

compareFunctions(funcA: VariadicFunction, funcB: VariadicFunction): { isEqual: boolean; differences: Difference[] }

Compares two boolean functions for equality based on their outputs for all possible input combinations.

  • funcA (VariadicFunction): The first function to compare.
  • funcB (VariadicFunction): The second function to compare.
  • Returns: An object with:
    • isEqual (boolean): Whether the functions are equal.
    • differences (Difference[]): An array of mismatches found.

generateTruthTable(func: VariadicFunction): TruthTableEntry[]

Generates a truth table for a given variadic boolean function.

  • func (VariadicFunction): The function to generate the truth table for.
  • Returns: An array of objects representing the truth table.

Keywords

boolean

FAQs

Package last updated on 11 Feb 2025

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