Skip to content

Commit

Permalink
Use the array helpers package to find unique items for xand and xnand
Browse files Browse the repository at this point in the history
  • Loading branch information
w3nl committed Jun 29, 2020
1 parent 53171a4 commit 541fc94
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -59,5 +59,8 @@
"logic",
"gates",
"logic gates"
]
],
"dependencies": {
"array-helpers": "^2.2.1"
}
}
6 changes: 2 additions & 4 deletions src/XandGate.mjs
@@ -1,11 +1,9 @@
import { Arr } from 'array-helpers';
import Gate from './Gate.mjs';

class XandGate extends Gate {
generateOutput() {
this.output =
this.inputs.filter(
(value, index, self) => self.indexOf(value) === index
).length <= 1;
this.output = new Arr(this.inputs).unique.length <= 1;
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/XnandGate.mjs
@@ -1,11 +1,9 @@
import { Arr } from 'array-helpers';
import Gate from './Gate.mjs';

class XnandGate extends Gate {
generateOutput() {
this.output =
this.inputs.filter(
(value, index, self) => self.indexOf(value) === index
).length > 1;
this.output = new Arr(this.inputs).unique.length > 1;
}
}

Expand Down

0 comments on commit 541fc94

Please sign in to comment.