2.0.4 • Published 4 years ago

@hckrnews/logic-gates v2.0.4

Weekly downloads
12
License
AGPL-3.0
Repository
github
Last release
4 years ago

Logic gates package

Generate logic gates without thinking. You can use this package if you need well tested logic gate checks. e.g. if all options must be true or false, but don't must be a mix of true and false, you can use the xand gate.

NPM version Build Status Coveralls Status Scrutinizer Code Quality

Installation

npm install @hckrnews/logic-gates or yarn add @hckrnews/logic-gates

Test the package

npm run test or yarn test

Usage

Example usage:

import { AndGate } from "@hckrnews/logic-gates";

const gate = AndGate.create([true, true]);

Send an array with boolean's to the create method.

Get the gate result:

gate.output

Output a boolean:

true

Or use the short syntax:

import { and } from "@hckrnews/logic-gates";

and([true, true])

Output a boolean:

true

All options:

Short syntax:

And gate

Input 1Input 2Input 3Output
0000
0010
0100
0110
1000
1010
1100
1111

Nand gate

Input 1Input 2Input 3Output
0001
0011
0101
0111
1001
1011
1101
1110

Or gate

Input 1Input 2Input 3Output
0000
0011
0101
0111
1001
1011
1101
1111

Nor gate

Input 1Input 2Input 3Output
0001
0010
0100
0110
1000
1010
1100
1110

Xor gate

Input 1Input 2Input 3Output
0000
0011
0101
0110
1001
1010
1100
1111

Xnor gate

Input 1Input 2Input 3Output
0001
0010
0100
0111
1000
1011
1101
1110

Xand gate

Input 1Input 2Input 3Output
0001
0010
0100
0110
1000
1010
1100
1111

Xnand gate

Input 1Input 2Input 3Output
0000
0011
0101
0111
1001
1011
1101
1110

Not gate

Input 1Input 2Input 3Output
0001,1,1
0011,1,0
0101,0,1
0111,0,0
1000,1,1
1010,1,0
1100,0,1
1110,0,0
2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago