1.10.38 โ€ข Published 6 months ago

extra-boolean.web v1.10.38

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Boolean data type has two possible truth values to represent logic. ๐Ÿ“ฆ Node.js, ๐ŸŒ Web, ๐Ÿ“œ Files, ๐Ÿ“ฐ Docs. ๐Ÿ“˜ Wiki.

A boolean data type has two possible truth values, usually represented as true or false. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century (REF). Boolean functions can be used to perform logical operations in computer programming, such as in conditional statements, loops, and branching, to compare input values with a set of rules to determine the output.

This is a collection of common boolean functions. It includes the basic gates not, and, or, xor; their complements nand, nor, xnor; and 2 propositional logic (taught in discrete mathematics) gates imply, eq; and their complements nimply, neq. There is also a multiplexer, called select, and a true counter, called count. count can help you make custom gates, such as an alternate concept of xnor which returns true only if all inputs are the same (standard xnor returns true if even inputs are true). These gates can handle up to eight inputs.

The parse function is influenced by (boolean) package, and is quite good at translating string to boolean. It can also handle double negatives, eg. not inactive. You know the and of 2-inputs, but what of 1-input? What of 0? And what of the other gates? I answer them here.

This package is available in Node.js and Web formats. To use it on the web, simply use the extra_boolean global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

const xboolean = require('extra-boolean');
// import * as xboolean from "extra-boolean";
// import * as xboolean from "https://unpkg.com/extra-boolean/index.mjs"; (deno)

xboolean.parse('1');
xboolean.parse('not off');
xboolean.parse('truthy');
// โ†’ true

xboolean.parse('not true');
xboolean.parse('inactive');
xboolean.parse('disabled');
// โ†’ false

xboolean.imply(true, false);
// โ†’ false

xboolean.eq(false, false);
// โ†’ true

xboolean.xor(true, true, true);
// โ†’ true

xboolean.select(1, true, false, true);
// โ†’ false                ^

xboolean.count(true, false, true);
// โ†’ 2         ^            ^

Index

PropertyDescription
isCheck if a value is boolean.
parseConvert a string to boolean.
notCheck if a boolean is false.
implyCheck if antecedent โ‡’ consequent.
nimplyCheck if antecedent โ‡ consequent.
eqCheck if antecedent โ‡” consequent.
neqCheck if antecedent โ‡Ž consequent.
andCheck if all booleans are true.
nandCheck if any boolean is false.
orCheck if any boolean is true.
norCheck if all booleans are false.
xorCheck if odd number of booleans are true.
xnorCheck if even number of booleans are true.
countCount number of true booleans.
selectCheck if iแต—สฐ boolean is true.

References

npm.io ORG DOI Coverage Status Test Coverage Maintainability

1.10.38

6 months ago

1.10.30

1 year ago

1.10.37

1 year ago

1.10.35

1 year ago

1.10.36

1 year ago

1.10.33

1 year ago

1.10.34

1 year ago

1.10.31

1 year ago

1.10.32

1 year ago

1.10.26

1 year ago

1.10.27

1 year ago

1.10.24

1 year ago

1.10.25

1 year ago

1.10.22

1 year ago

1.10.23

1 year ago

1.10.20

1 year ago

1.10.21

1 year ago

1.10.28

1 year ago

1.10.29

1 year ago

1.10.19

1 year ago

1.10.18

1 year ago

1.10.17

1 year ago

1.10.15

1 year ago

1.10.16

1 year ago

1.10.13

2 years ago

1.10.14

2 years ago

1.10.5

2 years ago

1.10.4

2 years ago

1.10.3

2 years ago

1.10.2

2 years ago

1.10.9

2 years ago

1.10.8

2 years ago

1.10.7

2 years ago

1.10.6

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.9.7

2 years ago

1.9.6

2 years ago

1.10.11

2 years ago

1.9.5

2 years ago

1.10.12

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.10.10

2 years ago

1.9.2

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.8.10

2 years ago

1.8.9

2 years ago

1.8.8

2 years ago

1.8.7

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago