Generate a truth table very easy. The generated truth tables can be used for e.a. test cases, if you would test a lot of situations.
npm install @hckrnews/truth-table
or
yarn add @hckrnews/truth-table
npm run test
or
yarn test
Example usage:
import AndTruthTable from "@hckrnews/truth-table";
const table = AndTruthTable.create(3);
Table inputs result:
table.inputs
Output:
[
[false, false, false],
[false, false, true],
[false, true, false],
[false, true, true],
[true, false, false],
[true, false, true],
[true, true, false],
[true, true, true],
]
To receive results of the and operator:
table.output
Output:
[false, false, false, false, false, false, false, true]
Do you with te receive the result with the inputs of the and operator:
table.result
Output:
[
[false, false, false, false],
[false, false, false, true],
[false, false, true, false],
[false, false, true, true],
[false, true, false, false],
[false, true, false, true],
[false, true, true, false],
[true, true, true, true],
]
All options:
- AndTruthTable
- NandTruthTable
- OrTruthTable
- NorTruthTable
- XoTruthTable
- XnoTruthTable
- XandTruthTable
- XnandTruthTable
- NotTruthTable
To check all used logic gates: https://www.npmjs.com/package/@hckrnews/logic-gates