@thi.ng/dlogic 2.1.18 → 2.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +6 -9
- package/index.d.ts +18 -18
- package/index.js +15 -15
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/dlogic)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -50,11 +50,8 @@ ES module import:
|
|
|
50
50
|
|
|
51
51
|
For Node.js REPL:
|
|
52
52
|
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
node --experimental-repl-await
|
|
56
|
-
|
|
57
|
-
> const dlogic = await import("@thi.ng/dlogic");
|
|
53
|
+
```js
|
|
54
|
+
const dlogic = await import("@thi.ng/dlogic");
|
|
58
55
|
```
|
|
59
56
|
|
|
60
57
|
Package sizes (brotli'd, pre-treeshake): ESM: 378 bytes
|
|
@@ -88,7 +85,7 @@ xor(true, true)
|
|
|
88
85
|
|
|
89
86
|
## Authors
|
|
90
87
|
|
|
91
|
-
Karsten Schmidt
|
|
88
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
92
89
|
|
|
93
90
|
If this project contributes to an academic publication, please cite it as:
|
|
94
91
|
|
|
@@ -103,4 +100,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
103
100
|
|
|
104
101
|
## License
|
|
105
102
|
|
|
106
|
-
© 2017 - 2022 Karsten Schmidt // Apache
|
|
103
|
+
© 2017 - 2022 Karsten Schmidt // Apache License 2.0
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { FnU2, FnU3, FnU4 } from "@thi.ng/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type Op2 = FnU2<boolean>;
|
|
3
|
+
type Op3 = FnU3<boolean>;
|
|
4
|
+
type Op4 = FnU4<boolean>;
|
|
5
5
|
export interface Sum<T> {
|
|
6
6
|
s: T;
|
|
7
7
|
c: boolean;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* https://en.wikipedia.org/wiki/Inverter_(logic_gate)
|
|
11
11
|
*
|
|
12
12
|
* | X | Q |
|
|
13
13
|
* |---|---|
|
|
@@ -18,7 +18,7 @@ export interface Sum<T> {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const not: (x: boolean) => boolean;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* https://en.wikipedia.org/wiki/NAND_gate
|
|
22
22
|
*
|
|
23
23
|
* | A | B | Q |
|
|
24
24
|
* |---|---|---|
|
|
@@ -32,7 +32,7 @@ export declare const not: (x: boolean) => boolean;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const nand: Op2;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* https://en.wikipedia.org/wiki/AND_gate
|
|
36
36
|
*
|
|
37
37
|
* | A | B | Q |
|
|
38
38
|
* |---|---|---|
|
|
@@ -46,7 +46,7 @@ export declare const nand: Op2;
|
|
|
46
46
|
*/
|
|
47
47
|
export declare const and: Op2;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* https://en.wikipedia.org/wiki/OR_gate
|
|
50
50
|
*
|
|
51
51
|
* | A | B | Q |
|
|
52
52
|
* |---|---|---|
|
|
@@ -60,7 +60,7 @@ export declare const and: Op2;
|
|
|
60
60
|
*/
|
|
61
61
|
export declare const or: Op2;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* https://en.wikipedia.org/wiki/NOR_gate
|
|
64
64
|
*
|
|
65
65
|
* | A | B | Q |
|
|
66
66
|
* |---|---|---|
|
|
@@ -74,7 +74,7 @@ export declare const or: Op2;
|
|
|
74
74
|
*/
|
|
75
75
|
export declare const nor: Op2;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* https://en.wikipedia.org/wiki/XOR_gate
|
|
78
78
|
*
|
|
79
79
|
* | A | B | Q |
|
|
80
80
|
* |---|---|---|
|
|
@@ -88,7 +88,7 @@ export declare const nor: Op2;
|
|
|
88
88
|
*/
|
|
89
89
|
export declare const xor: Op2;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* https://en.wikipedia.org/wiki/XNOR_gate
|
|
92
92
|
*
|
|
93
93
|
* | A | B | Q |
|
|
94
94
|
* |---|---|---|
|
|
@@ -102,7 +102,7 @@ export declare const xor: Op2;
|
|
|
102
102
|
*/
|
|
103
103
|
export declare const xnor: Op2;
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
105
|
+
* https://web.archive.org/web/20160304050642/http://www.zigwap.com/digital/gates/imply_gate
|
|
106
106
|
*
|
|
107
107
|
* | A | B | Q |
|
|
108
108
|
* |---|---|---|
|
|
@@ -115,7 +115,7 @@ export declare const xnor: Op2;
|
|
|
115
115
|
*/
|
|
116
116
|
export declare const imply: Op2;
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* https://en.wikipedia.org/wiki/AND-OR-Invert
|
|
119
119
|
*
|
|
120
120
|
* `q = nor(a, and(b, c))`
|
|
121
121
|
*
|
|
@@ -136,7 +136,7 @@ export declare const imply: Op2;
|
|
|
136
136
|
*/
|
|
137
137
|
export declare const aoi21: Op3;
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* https://en.wikipedia.org/wiki/AND-OR-Invert
|
|
140
140
|
*
|
|
141
141
|
* `q = nor(and(a, b), and(c, d))`
|
|
142
142
|
*
|
|
@@ -176,7 +176,7 @@ export declare const oai21: Op3;
|
|
|
176
176
|
*/
|
|
177
177
|
export declare const oai22: Op4;
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
179
|
+
* https://en.wikipedia.org/wiki/NAND_logic#MUX
|
|
180
180
|
*
|
|
181
181
|
* | A | B | S | Q |
|
|
182
182
|
* |---|---|---|---|
|
|
@@ -195,7 +195,7 @@ export declare const oai22: Op4;
|
|
|
195
195
|
*/
|
|
196
196
|
export declare const mux: Op3;
|
|
197
197
|
/**
|
|
198
|
-
*
|
|
198
|
+
* https://en.wikipedia.org/wiki/NAND_logic#DEMUX
|
|
199
199
|
*
|
|
200
200
|
* | I | S | A | B |
|
|
201
201
|
* |---|---|---|---|
|
|
@@ -209,14 +209,14 @@ export declare const mux: Op3;
|
|
|
209
209
|
*/
|
|
210
210
|
export declare const demux: FnU2<boolean, [boolean, boolean]>;
|
|
211
211
|
/**
|
|
212
|
-
*
|
|
212
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Half_adder
|
|
213
213
|
*
|
|
214
214
|
* @param a -
|
|
215
215
|
* @param b -
|
|
216
216
|
*/
|
|
217
217
|
export declare const hadd1: FnU2<boolean, Sum<boolean>>;
|
|
218
218
|
/**
|
|
219
|
-
*
|
|
219
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
|
|
220
220
|
*
|
|
221
221
|
* @param a -
|
|
222
222
|
* @param b -
|
|
@@ -224,7 +224,7 @@ export declare const hadd1: FnU2<boolean, Sum<boolean>>;
|
|
|
224
224
|
*/
|
|
225
225
|
export declare const fadd1: FnU3<boolean, Sum<boolean>>;
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
227
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Ripple-carry_adder
|
|
228
228
|
*
|
|
229
229
|
* @param a -
|
|
230
230
|
* @param b -
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* https://en.wikipedia.org/wiki/Inverter_(logic_gate)
|
|
3
3
|
*
|
|
4
4
|
* | X | Q |
|
|
5
5
|
* |---|---|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export const not = (x) => !x;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* https://en.wikipedia.org/wiki/NAND_gate
|
|
14
14
|
*
|
|
15
15
|
* | A | B | Q |
|
|
16
16
|
* |---|---|---|
|
|
@@ -24,7 +24,7 @@ export const not = (x) => !x;
|
|
|
24
24
|
*/
|
|
25
25
|
export const nand = (a, b) => !(a && b);
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* https://en.wikipedia.org/wiki/AND_gate
|
|
28
28
|
*
|
|
29
29
|
* | A | B | Q |
|
|
30
30
|
* |---|---|---|
|
|
@@ -38,7 +38,7 @@ export const nand = (a, b) => !(a && b);
|
|
|
38
38
|
*/
|
|
39
39
|
export const and = (a, b) => a && b;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* https://en.wikipedia.org/wiki/OR_gate
|
|
42
42
|
*
|
|
43
43
|
* | A | B | Q |
|
|
44
44
|
* |---|---|---|
|
|
@@ -52,7 +52,7 @@ export const and = (a, b) => a && b;
|
|
|
52
52
|
*/
|
|
53
53
|
export const or = (a, b) => a || b;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* https://en.wikipedia.org/wiki/NOR_gate
|
|
56
56
|
*
|
|
57
57
|
* | A | B | Q |
|
|
58
58
|
* |---|---|---|
|
|
@@ -66,7 +66,7 @@ export const or = (a, b) => a || b;
|
|
|
66
66
|
*/
|
|
67
67
|
export const nor = (a, b) => !(a || b);
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* https://en.wikipedia.org/wiki/XOR_gate
|
|
70
70
|
*
|
|
71
71
|
* | A | B | Q |
|
|
72
72
|
* |---|---|---|
|
|
@@ -80,7 +80,7 @@ export const nor = (a, b) => !(a || b);
|
|
|
80
80
|
*/
|
|
81
81
|
export const xor = (a, b) => a !== b;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* https://en.wikipedia.org/wiki/XNOR_gate
|
|
84
84
|
*
|
|
85
85
|
* | A | B | Q |
|
|
86
86
|
* |---|---|---|
|
|
@@ -94,7 +94,7 @@ export const xor = (a, b) => a !== b;
|
|
|
94
94
|
*/
|
|
95
95
|
export const xnor = (a, b) => a === b;
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* https://web.archive.org/web/20160304050642/http://www.zigwap.com/digital/gates/imply_gate
|
|
98
98
|
*
|
|
99
99
|
* | A | B | Q |
|
|
100
100
|
* |---|---|---|
|
|
@@ -107,7 +107,7 @@ export const xnor = (a, b) => a === b;
|
|
|
107
107
|
*/
|
|
108
108
|
export const imply = (a, b) => !a || b;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* https://en.wikipedia.org/wiki/AND-OR-Invert
|
|
111
111
|
*
|
|
112
112
|
* `q = nor(a, and(b, c))`
|
|
113
113
|
*
|
|
@@ -128,7 +128,7 @@ export const imply = (a, b) => !a || b;
|
|
|
128
128
|
*/
|
|
129
129
|
export const aoi21 = (a, b, c) => !(a || (b && c));
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* https://en.wikipedia.org/wiki/AND-OR-Invert
|
|
132
132
|
*
|
|
133
133
|
* `q = nor(and(a, b), and(c, d))`
|
|
134
134
|
*
|
|
@@ -168,7 +168,7 @@ export const oai21 = (a, b, c) => !(a && (b || c));
|
|
|
168
168
|
*/
|
|
169
169
|
export const oai22 = (a, b, c, d) => !((a || b) && (c || d));
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* https://en.wikipedia.org/wiki/NAND_logic#MUX
|
|
172
172
|
*
|
|
173
173
|
* | A | B | S | Q |
|
|
174
174
|
* |---|---|---|---|
|
|
@@ -187,7 +187,7 @@ export const oai22 = (a, b, c, d) => !((a || b) && (c || d));
|
|
|
187
187
|
*/
|
|
188
188
|
export const mux = (a, b, s) => (a && !s) || (b && s);
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* https://en.wikipedia.org/wiki/NAND_logic#DEMUX
|
|
191
191
|
*
|
|
192
192
|
* | I | S | A | B |
|
|
193
193
|
* |---|---|---|---|
|
|
@@ -204,7 +204,7 @@ export const demux = (i, s) => [
|
|
|
204
204
|
i && s,
|
|
205
205
|
];
|
|
206
206
|
/**
|
|
207
|
-
*
|
|
207
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Half_adder
|
|
208
208
|
*
|
|
209
209
|
* @param a -
|
|
210
210
|
* @param b -
|
|
@@ -214,7 +214,7 @@ export const hadd1 = (a, b) => ({
|
|
|
214
214
|
c: a && b,
|
|
215
215
|
});
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
217
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
|
|
218
218
|
*
|
|
219
219
|
* @param a -
|
|
220
220
|
* @param b -
|
|
@@ -225,7 +225,7 @@ export const fadd1 = (a, b, c) => ({
|
|
|
225
225
|
c: (a !== b && c) || (a && b),
|
|
226
226
|
});
|
|
227
227
|
/**
|
|
228
|
-
*
|
|
228
|
+
* https://en.wikipedia.org/wiki/Adder_(electronics)#Ripple-carry_adder
|
|
229
229
|
*
|
|
230
230
|
* @param a -
|
|
231
231
|
* @param b -
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dlogic",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.20",
|
|
4
4
|
"description": "Assorted digital logic ops / constructs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
37
|
+
"@thi.ng/api": "^8.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@microsoft/api-extractor": "^7.33.
|
|
41
|
-
"@thi.ng/testament": "^0.3.
|
|
40
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
41
|
+
"@thi.ng/testament": "^0.3.7",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"tools": "^0.0.1",
|
|
44
|
-
"typedoc": "^0.23.
|
|
45
|
-
"typescript": "^4.
|
|
44
|
+
"typedoc": "^0.23.22",
|
|
45
|
+
"typescript": "^4.9.4"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"boolean",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"thi.ng": {
|
|
71
71
|
"year": 2017
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
74
74
|
}
|