nand

Performs a logical NAND operation on the given arguments.

1. Code

/**
 * Performs a NAND (NOT AND) operation on the given arguments.
 * Returns `false` if no arguments are provided or if all arguments are truthy.
 * Returns `true` if any argument is falsy.
 *
 * @param args - The arguments to perform the NAND operation on.
 * @returns The result of the NAND operation.
 */
const nand = (...args: any[]) => {
  if (args.length === 0) return false;
  const and = args.every((arg) => Boolean(arg));
  return !and;
};

export default nand;

2. Installation

npx @jrtilak/lazykit@latest add nand -ts

3. Description

The and function is a utility function in TypeScript that performs a logical NAND operation on the given arguments.

4. Props

Prop

Type

Default Value

args*any[]---

5. Examples

import nand from ".";

console.log(nand(true, true));
// Expected Output: false

console.log(nand(true, false));
// Expected Output: true

console.log(nand());
// Expected Output: false

console.log(nand(1, "lazykit"));
// Expected Output: false