Pibd-21_Alekseev_I.S._Inter.../IP/node_modules/semver-compare/index.js
VanyaAlekseev c91124ead4 lab3
2023-12-21 21:08:22 +04:00

14 lines
372 B
JavaScript

module.exports = function cmp (a, b) {
var pa = a.split('.');
var pb = b.split('.');
for (var i = 0; i < 3; i++) {
var na = Number(pa[i]);
var nb = Number(pb[i]);
if (na > nb) return 1;
if (nb > na) return -1;
if (!isNaN(na) && isNaN(nb)) return 1;
if (isNaN(na) && !isNaN(nb)) return -1;
}
return 0;
};