check

Validation utilities for version comparison and other checks.

Functions

Function
Description
Example

version

Compare two version strings

dphelper.check.version('1.2.0', '1.1.0')

Description

Version comparison utilities:

  • Semantic Versioning - Compare version numbers

  • Custom Options - Lexicographic and zero-pad support

Usage Examples

Version Comparison

// Compare versions
console.log(dphelper.check.version('1.2.0', '1.1.0'));  // 1 (v1 > v2)
console.log(dphelper.check.version('1.1.0', '1.2.0'));  // -1 (v1 < v2)
console.log(dphelper.check.version('1.0.0', '1.0.0'));  // 0 (equal)

// With zero padding
console.log(dphelper.check.version('1.2', '1.2.0', { zero: true })); // 0

// With lexicographic comparison
console.log(dphelper.check.version('1.0.0a', '1.0.0b', { lex: true })); // -1

Software Update Checker

Details

  • Author: Dario Passariello

  • Version: 0.0.2

  • Creation Date: 20240829

  • Last Modified: 20240829

  • Environment: Works in both client and server environments


Automatically generated document

Last updated