1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function is(v) {
|
6 | return typeof v === "boolean";
|
7 | }
|
8 |
|
9 | function imply(a, b) {
|
10 | return !a || b;
|
11 | }
|
12 |
|
13 | function nimply(a, b) {
|
14 | return !imply(a, b);
|
15 | }
|
16 |
|
17 | const RNUM = /^[-+]?\d+$/;
|
18 | const RTRU = /\b(?:t|y|1)\b|\b(?:\+|ay|go|on|up)|(?:tru|acc|asc|day|for|hot|inc|joy|new|pos|top|win|yes|dawn|full|safe|grow|high|just|real|some|know|live|love|open|pure|shin|warm|wis[de]|activ|admit|advan|agree|begin|brigh|build|creat|early|enter|float|f(?:i|ou)nd|grant|light|north|prett|prese|publi|start|succe|victr)/gi;
|
19 | const RFAL = /\b(?:f|n|0)\b|(?:fal|off|dim|end|low|old|back|cold|cool|dark|dead|decr|desc|dirt|down|dull|dusk|exit|late|sink|ugly|absen|botto|close|finis|night|priva|south|wrong)/gi;
|
20 | const RNEG = /\b(?:-|na|no|un|in|aft|bad|dis|lie|non|ben[dt]|den[iy]|empt|fail|fake|hate|los[es]|stop|decli|defea|destr|never|negat|refus|rejec|forget|shr[iu]nk|against|is.?nt|can.?(?:no)?t)|(?:hind)/gi;
|
21 | function parse(s) {
|
22 | if (RNUM.test(s))
|
23 | return parseInt(s, 10) > 0;
|
24 | var t = s.search(RTRU) >= 0;
|
25 | var f = s.search(RFAL) >= 0;
|
26 | var n = (s.match(RNEG) || []).length % 2 === 1;
|
27 | return nimply(f, t) === n;
|
28 | }
|
29 |
|
30 | function not(a) {
|
31 | return !a;
|
32 | }
|
33 |
|
34 | function eq(a, b) {
|
35 | return a === b;
|
36 | }
|
37 |
|
38 | function neq(a, b) {
|
39 | return !eq(a, b);
|
40 | }
|
41 |
|
42 | function imp(a, b) {
|
43 | return imply(a, b);
|
44 | }
|
45 |
|
46 | function eqv(a, b) {
|
47 | return eq(a, b);
|
48 | }
|
49 |
|
50 | function and(a = true, b = true, c = true, d = true, e = true, f = true, g = true, h = true) {
|
51 | return a && b && c && d && e && f && g && h;
|
52 | }
|
53 |
|
54 | function nand(a = true, b = true, c = true, d = true, e = true, f = true, g = true, h = true) {
|
55 | return !and(a, b, c, d, e, f, g, h);
|
56 | }
|
57 |
|
58 | function or(a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
59 | return a || b || c || d || e || f || g || h;
|
60 | }
|
61 |
|
62 | function nor(a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
63 | return !or(a, b, c, d, e, f, g, h);
|
64 | }
|
65 |
|
66 | function xor(a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
67 | return a !== b !== c !== d !== e !== f !== g !== h;
|
68 | }
|
69 |
|
70 | function xnor(a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
71 | return !xor(a, b, c, d, e, f, g, h);
|
72 | }
|
73 |
|
74 | function count(a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
75 | return (a ? 1 : 0) + (b ? 1 : 0) + (c ? 1 : 0) + (d ? 1 : 0) +
|
76 | (e ? 1 : 0) + (f ? 1 : 0) + (g ? 1 : 0) + (h ? 1 : 0);
|
77 | }
|
78 |
|
79 | function select(i, a = false, b = false, c = false, d = false, e = false, f = false, g = false, h = false) {
|
80 | switch (i) {
|
81 | case 0: return a;
|
82 | case 1: return b;
|
83 | case 2: return c;
|
84 | case 3: return d;
|
85 | case 4: return e;
|
86 | case 5: return f;
|
87 | case 6: return g;
|
88 | case 7: return h;
|
89 | default: return false;
|
90 | }
|
91 | }
|
92 |
|
93 | exports.and = and;
|
94 | exports.count = count;
|
95 | exports.eq = eq;
|
96 | exports.eqv = eqv;
|
97 | exports.imp = imp;
|
98 | exports.imply = imply;
|
99 | exports.is = is;
|
100 | exports.nand = nand;
|
101 | exports.neq = neq;
|
102 | exports.nimply = nimply;
|
103 | exports.nor = nor;
|
104 | exports.not = not;
|
105 | exports.or = or;
|
106 | exports.parse = parse;
|
107 | exports.select = select;
|
108 | exports.xnor = xnor;
|
109 | exports.xor = xor;
|