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 🙏

© 2026 – Pkg Stats / Ryan Hefner

proplogic

v1.0.1

Published

Propositional logic expressions validator and parser.

Readme

proplogic

npm version npm downloads

A lightweight JavaScript library for tokenizing, formatting, and validating propositional logic expressions.

Installation

npm install proplogic

Quick Start

import { lexp } from 'proplogic';

lexp.validate('P∧Q');   // true
lexp.validate('P∧');    // false
lexp.validate('P & Q'); // true

API

lexp.validate(expression)

Validates whether a string is a well-formed propositional logic formula.

Parameters

  • expression {string} — the formula to validate.

Returns {boolean}true if the formula is well-formed, false otherwise.

Whitespace is ignored. Invalid or unrecognized characters return false.

lexp.validate('P∧Q');     // true
lexp.validate('(P∨Q)→R'); // true
lexp.validate('¬(¬P)');   // true
lexp.validate('∧P');      // false
lexp.validate('P∧∧Q');    // false
lexp.validate(')(P)');    // false

lexp.tokenize(expression)

Tokenizes a propositional logic expression into an array of typed tokens.

Parameters

  • expression {string} — the expression to tokenize.

Returns {Array<{type: string, value: string}>} — an array of token objects, or false if the expression contains invalid characters.

Throws Error - Expression can not be formatted.

Token types: operand, operator, not, open, close.

lexp.tokenize('P∧Q');
// [
//   { type: 'operand',  value: 'P' },
//   { type: 'operator', value: '∧' },
//   { type: 'operand',  value: 'Q' }
// ]

lexp.tokenize('P & Q');
// [
//   { type: 'operand',  value: 'P' },
//   { type: 'operator', value: '∧' },  ← alias normalized
//   { type: 'operand',  value: 'Q' }
// ]

lexp.format(expression)

Normalizes an expression by stripping whitespace and replacing ASCII aliases with their canonical Unicode symbols.

Parameters

  • expression {string} — the expression to format.

Returns {string} — the normalized expression.

Throws Error — Expression can not te formatted.

lexp.format('P & Q');  // 'P∧Q'
lexp.format('P | Q');  // 'P∨Q'
lexp.format('!P > Q'); // '¬P→Q'
lexp.format('P = Q');  // 'P↔Q'

confusablesTable

An exported object mapping ASCII aliases and Unicode lookalikes to their canonical logic symbols. Useful for displaying supported input formats to users.

import { confusablesTable } from 'proplogic';

console.log(confusablesTable);
// { 'V': '∨', 'v': '∨', '&': '∧', '^': '∧', '~': '¬', '!': '¬', ... }

Supported Symbols

Operators

| Symbol | Meaning | ASCII Aliases | |--------|---------|---------------| | | Conjunction (AND) | &, ^, · | | | Disjunction (OR) | v, V, \|, | | | Implication | >, , | | | Biconditional | =, , | | | Not Equals | , | | | Exclusive OR (XOR) | +, | | | NAND | | | | NOR | | | ¬ | Negation (NOT) | ~, ! |

Grouping

| Symbol | Meaning | Aliases | |--------|---------|---------| | ( | Open parenthesis | [, {, , | | ) | Close parenthesis | ], }, , |

Operands

Any single character matching [A-Za-z] or falling in the Unicode Greek block (U+0370–U+03FF) is treated as an operand (e.g., P, q, α, φ).


Testing

npm run test

Tests are run with Bun. Make sure you have Bun installed before running them.

curl -fsSL https://bun.sh/install | bash

Contributing

Feel free to open a PR or create an issue at repository link.

Additions to the characters map or confusables are welcome, as well as code changes.


License

MIT