logical-gates-ts

A simple (zero-depths) library to try logical operators

Usage no npm install needed!

<script type="module">
  import logicalGatesTs from 'https://cdn.skypack.dev/logical-gates-ts';
</script>

README

Logical Gates

A simple (zero-dependencies) library to implement logic gates in JavaScript/TypeScript.

CircleCI types GitHub code size in bytes Codacy Badge Codacy Badge

Installation

Using NPM:

npm install logical-gates-ts

Using Yarn:

yarn add logical-gates-ts

Using pnpm:

pnpm add logical-gates-ts

How it works

This section provide the mathematical/logical description scheme for each logic gate

AND

INPUT OUTPUT
000
010
100
111

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.AND(true, false) // -> false

OR

INPUT OUTPUT
000
011
101
111

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.OR(true, false) // -> true

XOR

INPUT OUTPUT
000
011
101
110

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.XOR(true, false) // -> true

NAND

INPUT OUTPUT
001
011
101
110

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.NAND(true, false) // -> true

NOR

INPUT OUTPUT
001
010
100
110

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.NOR(true, false) // -> false

XNOR

INPUT OUTPUT
000
011
101
110

Example:

import { LogicalGates } from 'logical-gates-ts'

LogicalGates.XNOR(true, false) // -> true