booleanlab
Version:
A comprehensive TypeScript utility library for advanced boolean operations. Simplify your boolean logic with easy-to-use functions.
203 lines (143 loc) • 4.36 kB
Markdown
A comprehensive TypeScript utility library for advanced boolean operations. Simplify your boolean logic with easy-to-use functions.
---
Install `booleanlab` via npm or yarn:
```bash
npm install booleanlab
```
```bash
yarn add booleanlab
```
---
Import the required functions into your TypeScript or JavaScript project:
```typescript
import { trueValue, falseValue, isEqual, andOperation } from 'booleanlab';
console.log(trueValue()); // true
console.log(falseValue()); // false
console.log(isEqual(true, false)); // false
console.log(andOperation(true, false)); // false
```
---
Returns the boolean value `true`.
```typescript
trueValue(); // true
```
Returns the boolean value `false`.
```typescript
falseValue(); // false
```
Returns `true` if both boolean values are equal, `false` otherwise.
```typescript
isEqual(true, true); // true
isEqual(true, false); // false
```
Returns `true` if both boolean values are not equal, `false` otherwise.
```typescript
isNotEqual(true, false); // true
isNotEqual(false, false); // false
```
Performs a logical AND operation on two boolean values.
```typescript
andOperation(true, true); // true
andOperation(true, false); // false
```
Performs a logical OR operation on two boolean values.
```typescript
orOperation(true, false); // true
orOperation(false, false); // false
```
Performs a logical XOR (exclusive OR) operation.
```typescript
xorOperation(true, false); // true
xorOperation(true, true); // false
```
Returns the negation (inverse) of a boolean value.
```typescript
negate(true); // false
negate(false); // true
```
Checks if a value is exactly `true`.
```typescript
isTrue(true); // true
isTrue(false); // false
```
Checks if a value is exactly `false`.
```typescript
isFalse(false); // true
isFalse(true); // false
```
Converts a boolean to a binary number (`1` for `true`, `0` for `false`).
```typescript
toBinary(true); // 1
toBinary(false); // 0
```
Converts any value to a boolean (falsy values become `false`, truthy values become `true`).
```typescript
toBoolean(1); // true
toBoolean(0); // false
toBoolean(null); // false
```
Performs a logical NAND (NOT AND) operation.
```typescript
nandOperation(true, true); // false
nandOperation(false, true); // true
```
Performs a logical NOR (NOT OR) operation.
```typescript
norOperation(false, false); // true
norOperation(true, false); // false
```
Converts a boolean value to a string representation (`"True"` or `"False"`).
```typescript
toString(true); // "True"
toString(false); // "False"
```
Checks if a value is truthy (not `null`, `undefined`, `false`, `0`, `NaN`, or an empty string).
```typescript
isTruthy(1); // true
isTruthy(''); // false
isTruthy(null); // false
```
Checks if a value is falsy (`null`, `undefined`, `false`, `0`, `NaN`, or an empty string).
```typescript
isFalsy(0); // true
isFalsy(true); // false
```
Returns the result of a logical Implication (A → B) operation.
```typescript
implication(true, false); // false
implication(false, true); // true
```
Returns the result of a logical Biconditional (A ↔ B) operation.
```typescript
biConditional(true, true); // true
biConditional(true, false); // false
```
---
This project is licensed under the **ISC License**.
---
Created by **jella_komal**.