UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

16 lines (15 loc) 584 B
/** * compareVersion compares two version strings and returns: * 0 if both versions are equal, * 1 if v1 is greater than v2, * -1 if v2 is greater than v1. * * @param v1 The first version string (e.g., "1.2.3"). * @param v2 The second version string (e.g., "1.2.4"). * @returns 0 if both versions are equal, 1 if v1 > v2, -1 if v2 > v1. * @example * compareVersion("1.2.3", "1.2.4"); // returns -1 * compareVersion("1.2.3", "1.2.3"); // returns 0 * compareVersion("1.2.4", "1.2.3"); // returns 1 */ export default function compareVersion(v1: string, v2: string): number;