@cute-dw/core
Version:
This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need
68 lines (67 loc) • 1.97 kB
TypeScript
import { Compare } from "./function/Compare";
/**
* This utility class contains value's comparison methods using their natural ordering
*/
export declare class Comparator<T> {
private static _instance;
private _compare;
/**
* Constructor.
* @param compareFunction - It may be custom compare function that, let's say may compare custom objects together.
*
*/
constructor(compareFunction?: Compare<T>);
/**
* Default comparison function
* @param a The first value to compare
* @param b The second value to compare
* @returns {number} `0` if the both values are equal, `-1` if the value _a_ is less then _b_, otherwise returns `1`
* @static
*/
static compare<T>(a: T, b: T): number;
/**
* Gets comparator singleton
* @returns Singleton object
* @static
*/
static getInstance(): Comparator<any>;
/**
* Checks if two variables are equal.
* @param {*} a
* @param {*} b
* @return {boolean}
*/
equal(a: T | null, b: T | null): boolean;
/**
* Checks if variable "a" is less than "b".
* @param {*} a
* @param {*} b
* @return {boolean}
*/
lessThan(a: T | null, b: T | null): boolean;
/**
* Checks if variable "a" is greater than "b".
* @param {*} a
* @param {*} b
* @return {boolean}
*/
greaterThan(a: T | null, b: T | null): boolean;
/**
* Checks if variable "a" is less than or equal to "b".
* @param {*} a
* @param {*} b
* @return {boolean}
*/
lessThanOrEqual(a: T | null, b: T | null): boolean;
/**
* Checks if variable "a" is greater than or equal to "b".
* @param {*} a
* @param {*} b
* @return {boolean}
*/
greaterThanOrEqual(a: T | null, b: T | null): boolean;
/**
* Reverses the comparison order.
*/
reverse(): void;
}