nor

Performs a logical NOR operation on the given arguments.

1. Code

/**
 * Performs a logical NOR operation on the given arguments.
 * Returns true if none of the arguments are truthy, otherwise returns false.
 *
 * @param args - The arguments to perform the NOR operation on.
 * @returns The result of the NOR operation.
 */
const nor = (...args: any[]) => {
  if (args.length === 0) return false;
  const or = args.some((arg) => Boolean(arg));
  return !or;
};

export default nor;

2. Installation

npx @jrtilak/lazykit@latest add nor -ts

3. Description

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

4. Props

Prop

Type

Default Value

args*any[]---

5. Examples

import or from ".";

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

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

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

console.log(or());
// Expected Output: true

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