sussy-util
Version:
Util package made by me
38 lines (37 loc) • 1.35 kB
TypeScript
/**
* Represents a tuple with two elements of types A and B.
* @template A - The type of the first element.
* @template B - The type of the second element.
*/
export default class Tuple<A, B> {
readonly first: A;
readonly second: B;
/**
* Creates a new Tuple instance with the specified first and second elements.
* @param {A} first - The first element of the tuple.
* @param {B} second - The second element of the tuple.
*/
constructor(first: A, second: B);
/**
* Swaps the first and second elements of the tuple.
* @returns {Tuple<B, A>} A new Tuple with the elements swapped.
*/
swap: () => Tuple<B, A>;
/**
* Checks if the tuple contains a specific value.
* @param {A | B} value - The value to check for in the tuple.
* @returns {boolean} - True if the value is found, false otherwise.
*/
contains: (value: A | B) => boolean;
/**
* Returns a string representation of the tuple.
* @returns {string} The string representation of the tuple.
*/
toString: () => string;
/**
* Compares this tuple to another tuple of the same type.
* @param {unknown} other - The tuple to compare against.
* @returns {boolean} True if both tuples have the same elements, false otherwise.
*/
equals: (other: unknown) => boolean;
}