Skip to content

Logic

either()

Computes the result of the logical OR operation.

  • Type
  • Details

Takes two boolean parameters and returns .

  • Example
js
either(true, false); // true

either(false)(false); // false
either(true, false); // true

either(false)(false); // false

both()

Computes the result of the logical AND operation.

  • Type
  • Details

Takes two boolean parameters and returns .

  • Example
js
both(true, false); // false

both(true)(true); // true
both(true, false); // false

both(true)(true); // true

not()

Computes the result of the NOT operation.

  • Type
  • Details

Takes one boolean parameter and returns .

  • Example
js
not(false); // true
not(false); // true

lt()

Computes the result of the operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
lt(2, 3); // true

lt(3)(3); // false
lt(2, 3); // true

lt(3)(3); // false

lte()

Computes the result of the $ \leq $ operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
lte(2, 3); // true

lte(3)(3); // true
lte(2, 3); // true

lte(3)(3); // true

gt()

Computes the result of the operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
gt(2, 3); // false

gt(3)(3); // false
gt(2, 3); // false

gt(3)(3); // false

gte()

Computes the result of the operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
gte(2, 3); // false

gte(3)(3); // true
gte(2, 3); // false

gte(3)(3); // true

equal()

Computes the result of the operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
equal(1, 1); // true

equal(5)(1); // false
equal(1, 1); // true

equal(5)(1); // false

equalStrict()

Computes the result of the operation.

  • Type
  • Details

Takes two comparable parameters and returns .

  • Example
js
equalStrict(1, 1); // true

equalStrict(5)(1); // false
equalStrict(1, 1); // true

equalStrict(5)(1); // false

deepEqual()

Compares whether two values (which can be arrays, objects, or general values) are equal.

  • Type
  • Details

Takes two values and returns whether they are deeply equal or not.

  • Example
js
deepEqual([1, 2, 3], [4, 5, 6]); // false
deepEqual({ a: 1 }, { a: 1 }); // true
deepEqual([1, 2, 3], [4, 5, 6]); // false
deepEqual({ a: 1 }, { a: 1 }); // true

when()

Constructs a function that performs a certain operation when a condition is met.

  • Type
  • Details

Initially takes two function-type parameters , and returns a function that takes a single argument. If the argument satisfies , it will execute and return its result; otherwise, it will return the original argument.

  • Example
js
const foo = when(
    (v) => v == ' is you!',
    (v) => 'homo' + v
);
foo(' is you!'); // "homo is you!"
const foo = when(
    (v) => v == ' is you!',
    (v) => 'homo' + v
);
foo(' is you!'); // "homo is you!"

unless()

Constructs a function that performs a certain operation when a condition is not met.

  • Type
  • Details

Initially takes two function-type parameters , and returns a function that takes a single argument. If the argument does not satisfy , it will execute and return its result; otherwise, it will return the original argument.

  • Example
js
const foo = unless(
    (v) => !(v == ' is you!'),
    (v) => 'homo' + v
);
foo(' is you!'); // "homo is you!"
const foo = unless(
    (v) => !(v == ' is you!'),
    (v) => 'homo' + v
);
foo(' is you!'); // "homo is you!"

ifElse()

Constructs a function that performs a certain operation based on a condition.

  • Type
  • Details

Initially takes three function-type parameters , and returns a function that takes a single argument. If the argument satisfies , it will execute and return its result; otherwise, it will execute and return its result.

  • Example
js
const foo = ifElse(
    (v) => v == ' is you!',
    (v) => 'homo' + v,
    (v) => 'homo' + v
);
foo(' not you!'); // "homo not you!"
const foo = ifElse(
    (v) => v == ' is you!',
    (v) => 'homo' + v,
    (v) => 'homo' + v
);
foo(' not you!'); // "homo not you!"

id()

Returns the passed-in argument.

  • **

Type**

  • Details

Takes an argument and returns it directly.

  • Example
js
id(114514); // 114514
id(114514); // 114514

always()

Constructs a function that returns a constant value.

  • Type
  • Details

Takes a constant value and returns a function that, when invoked, returns this constant value.

  • Example
js
always(114514)(); // 114514
always(114514)(); // 114514

eqType()

Determines if the types of two values are equal.

  • Type
  • Details

Takes two values and returns whether their types are equal.

  • Example
js
eqType(1, 1); // true
eqType(1, '1'); // false
eqType(1, 1); // true
eqType(1, '1'); // false

eqData()

Compares whether two abstract data structures are equal.

  • Type
  • Details

Takes two objects constructed by the Data API. The function can determine whether these two objects are from the same abstract data structure and are equal.

  • Example
js
const foo = Data('A a b c');
eqData(foo.A(1, 1, 2), foo.A(1, 1, 2)); // true
const foo = Data('A a b c');
eqData(foo.A(1, 1, 2), foo.A(1, 1, 2)); // true

PureEval released under the GPL-3.0 License.