Staquia API
    Preparing search index...

    Interface IOrdinal<T>

    Explicit comparisons between two objects of the same kind. Positions implement it, and the result always agrees with the order of their strings.

    interface IOrdinal<T> {
        compare(other: T): Ordering;
        equal(other: T): boolean;
        greater(this: T, other: T): boolean;
        greaterOrEqual(this: T, other: T): boolean;
        less(this: T, other: T): boolean;
        lessOrEqual(this: T, other: T): boolean;
    }

    Type Parameters

    • T

      The type of the compared objects.

    Hierarchy (View Summary)

    Index

    Methods

    • Compares this with other, like a sort comparator.

      Parameters

      • other: T

        The object to compare with.

      Returns Ordering

      "less" if this goes before other, "equal" if they have the same value, "greater" if it goes after.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm!m");
      const b = system.forge("mmmmn");

      if (a.ok && b.ok) console.log(a.value.compare(b.value)); // "less"
    • Checks if this and other have the same value.

      Parameters

      • other: T

        The object to compare with.

      Returns boolean

      true if both have the same value.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm");
      const b = system.forge("mmmmm!");

      // Zeroes to the right don't change the value
      if (a.ok && b.ok) console.log(a.value.equal(b.value)); // true
    • Checks if this goes after other.

      Parameters

      • this: T

        The left side of the comparison.

      • other: T

        The right side of the comparison.

      Returns boolean

      true if this > other.

    • Checks if this goes after other or has the same value.

      Parameters

      • this: T

        The left side of the comparison.

      • other: T

        The right side of the comparison.

      Returns boolean

      true if this >= other.

    • Checks if this goes before other.

      Parameters

      • this: T

        The left side of the comparison.

      • other: T

        The right side of the comparison.

      Returns boolean

      true if this < other.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm!m");
      const b = system.forge("mmmmn");

      if (a.ok && b.ok) {
      console.log(a.value.less(b.value)); // true
      console.log(a.value.greater(b.value)); // false
      }
    • Checks if this goes before other or has the same value.

      Parameters

      • this: T

        The left side of the comparison.

      • other: T

        The right side of the comparison.

      Returns boolean

      true if this <= other.