Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions src/compare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";

/* -----------------------------------------------------------
COMPARE FUNCTIONS
----------------------------------------------------------- */
/**
* Compare namespace for value comparison operations.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export namespace compare {
/**
* Tests whether `x` covers `y`.
*
* Tests a parametric value type and returns whether `x` covers `y` or not.
* If the parametric value `x` covers `y`, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric value `x` covers `y` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function covers<T>(x: T, y: T): boolean;

/**
* Tests whether `x` covers `y`.
*
* Tests a parametric value type and returns whether `x` covers `y` or not.
* If the parametric value `x` covers `y`, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric value `x` covers `y` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function covers<T>(x: unknown, y: unknown): boolean;

/**
* @internal
*/
export function covers(): never {
NoTransformConfigurationError("compare.covers");
}

/**
* Tests equality between two values.
*
* Tests a parametric value type and returns whether `x` and `y` are equal or not.
* If the parametric values are deeply equal, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric values are equal or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function equals<T>(x: T, y: T): boolean;

/**
* Tests equality between two values.
*
* Tests a parametric value type and returns whether `x` and `y` are equal or not.
* If the parametric values are deeply equal, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric values are equal or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function equals<T>(x: unknown, y: unknown): boolean;

/**
* @internal
*/
export function equals(): never {
NoTransformConfigurationError("compare.equals");
}

/**
* Tests whether `x` is less than `y`.
*
* Tests a parametric value type and returns whether `x` is less than `y` or not.
* If the parametric value `x` is less than `y`, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric value `x` is less than `y` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function less<T>(x: T, y: T): boolean;

/**
* Tests whether `x` is less than `y`.
*
* Tests a parametric value type and returns whether `x` is less than `y` or not.
* If the parametric value `x` is less than `y`, `true` value will be returned.
* Otherwise, `false` value will be returned.
*
* @template T Type of the input values
* @param x First value to be compared
* @param y Second value to be compared
* @returns Whether the parametric value `x` is less than `y` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function less<T>(x: unknown, y: unknown): boolean;

/**
* @internal
*/
export function less(): never {
NoTransformConfigurationError("compare.less");
}
}
1 change: 1 addition & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * as notations from "./notations";
export * as protobuf from "./protobuf";
export * as reflect from "./reflect";
export * as tags from "./tags";
export * as compare from "./compare";

export * from "./schemas/metadata/IJsDocTagInfo";
export * from "./schemas/json/IJsonApplication";
Expand Down
Loading