A simple (zero-dependencies) library to implement logic gates in JavaScript/TypeScript.
Using NPM:
npm install logical-gates-ts
Using Yarn:
yarn add logical-gates-ts
Using pnpm:
pnpm add logical-gates-ts
This section provide the mathematical/logical description scheme for each logic gate
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.AND(true, false) // -> false
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.OR(true, false) // -> true
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.XOR(true, false) // -> true
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.NAND(true, false) // -> true
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.NOR(true, false) // -> false
INPUT | OUTPUT | |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Example:
import { LogicalGates } from 'logical-gates-ts'
LogicalGates.XNOR(true, false) // -> true