Skip to content

Commit

Permalink
Organize files and fix "and" and "or" function to receive multiple args
Browse files Browse the repository at this point in the history
  • Loading branch information
201flaviosilva committed Oct 17, 2022
1 parent 06c75f5 commit 2473d08
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 134 deletions.
15 changes: 0 additions & 15 deletions src/and.js

This file was deleted.

29 changes: 9 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Games from "./Games/index.js";
import * as SortingAlgorithms from "./SortingAlgorithms/index.js";

import { allCharactersSame } from "./allCharactersSame.js";
import { and } from "./and.js";
import { arrayAllEqual } from "./arrayAllEqual.js";
import { arrayChoice } from "./arrayChoice.js";
import { arrayFindBigObject } from "./arrayFindBigObject.js";
Expand Down Expand Up @@ -42,16 +41,13 @@ import { isNarcissisticNumber } from "./isNarcissisticNumber.js";
import { isFalsy, isTruthy } from "./isTruthyFalsy.js";
import { stringToKebabCase, kebabCaseToNormal } from "./kebabCase.js";
import { lerp } from "./lerp.js";
import { and, or, xor } from "./logicalOperators.js";
import { LIFO } from "./LIFO.js";
import { makeNegative } from "./makeNegative.js";
import { map } from "./map.js";
import { median } from "./median.js";
import { mode } from "./mode.js";
import { multiplication } from "./multiplication.js";
import { nand } from "./nand.js";
import { nor } from "./nor.js";
import { not } from "./not.js";
import { or } from "./or.js";
import { radiansToDegrees } from "./radiansToDegrees.js";
import { randomColor, randomColor0X, randomRGBColor, randomRGBAColor } from "./randomColor.js";
import { randomNumber, randomInt, randomFloat } from "./randomNumber.js";
Expand All @@ -64,16 +60,20 @@ import { subtraction } from "./subtraction.js";
import { sum } from "./sum.js";
import { topDownCarMovimentation } from "./topDownCarMovimentation.js";
import { Vector2 } from "./Vector2.js";
import { xnor } from "./xnor.js";
import { xor } from "./xor.js";

export {
DOM,
Games,
SortingAlgorithms,

BinarySearchTree, BinarySearchTreeInstance,
EventSystem, EventSystemInstance,
Fibonacci, fibonacciSequence, fibonacciUntil, fibonacciCustomSequence, recursiveFibonacci,
FIFO,
LIFO,
Vector2,

allCharactersSame,
and,
arrayAllEqual,
arrayChoice,
arrayFindBigObject,
Expand All @@ -85,7 +85,6 @@ export {
arraySortDescending, arraySortDescendingObject,
average,
binary2Decimal,
BinarySearchTree, BinarySearchTreeInstance,
stringToCamelCase, camelCaseToNormal,
stringToCapitalize, capitalizeToNormal,
clamp,
Expand All @@ -95,9 +94,6 @@ export {
degreesToRadians,
division,
divideEvenly,
EventSystem, EventSystemInstance,
Fibonacci, fibonacciSequence, fibonacciUntil, fibonacciCustomSequence, recursiveFibonacci,
FIFO,
getDate, // getTime, getMilliseconds, getSeconds, getMinutes, getHours, getDay, getWeekDay, getWeek, getMonth, getYear, getDateFormatted,
getPositionWithAngleDistance,
getUrlParameter,
Expand All @@ -110,16 +106,12 @@ export {
isFalsy, isTruthy,
stringToKebabCase, kebabCaseToNormal,
lerp,
LIFO,
and, or, xor, // logicalOperators
makeNegative,
map,
median,
mode,
multiplication,
nand,
nor,
not,
or,
radiansToDegrees,
randomColor, randomColor0X, randomRGBColor, randomRGBAColor,
randomNumber, randomInt, randomFloat,
Expand All @@ -131,7 +123,4 @@ export {
subtraction,
sum,
topDownCarMovimentation,
Vector2,
xnor,
xor
};
49 changes: 49 additions & 0 deletions src/logicalOperators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Compare if there is truthy value.
* Return true if all values are truthy.
*
* @example
* and(false, false, false); // false
* and(true, false, false); // false
* and(true, false, true); // false
* and(true, true, true); // true
*
* @param {any} args - values to check
* @returns {boolean}
*/
export function and(...args) {
for (let i = 0; i < args.length; i++) {
if (!args[i]) return false;
}
return true;
};

/**
* Compare if one of the value are truthy.
* Return true if one are truthy.
*
* @example
* or(false, false, false); // false
* or(true, false, true); // true
* or(false, true, false); // true
* or(true, true, true); // true
*
* @param {any} args - values to check
* @returns {boolean}
*/
export function or(...args) { return !!args.find(a => !!a) };

/**
* Return false if both values are truthy ou falsy.
*
* @example
* xor(false, false); // false
* xor(true, false); // true
* xor(false, true); // true
* xor(true, true); // false
*
* @param {any} value1 - value 1 to compare
* @param {any} value2 - value 2 to compare
* @returns {boolean}
*/
export function xor(value1, value2) { return !!value1 !== !!value2 };
18 changes: 0 additions & 18 deletions src/nand.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/nor.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/not.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/or.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/xnor.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/xor.js

This file was deleted.

0 comments on commit 2473d08

Please sign in to comment.