feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@ -2,21 +2,25 @@
// eslint-disable-next-line es/no-object-hasown -- safe
const has = Object.hasOwn || Function.call.bind({}.hasOwnProperty);
function semver(input) {
if (input instanceof semver) return input;
// eslint-disable-next-line new-cap -- ok
if (!(this instanceof semver)) return new semver(input);
const match = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(input);
if (!match) throw new TypeError(`Invalid version: ${ input }`);
const [, $major, $minor, $patch] = match;
this.major = +$major;
this.minor = $minor ? +$minor : 0;
this.patch = $patch ? +$patch : 0;
const VERSION_PATTERN = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
class SemVer {
constructor(input) {
const match = VERSION_PATTERN.exec(input);
if (!match) throw new TypeError(`Invalid version: ${ input }`);
const [, $major, $minor, $patch] = match;
this.major = +$major;
this.minor = $minor ? +$minor : 0;
this.patch = $patch ? +$patch : 0;
}
toString() {
return `${ this.major }.${ this.minor }.${ this.patch }`;
}
}
semver.prototype.toString = function () {
return `${ this.major }.${ this.minor }.${ this.patch }`;
};
function semver(input) {
return input instanceof SemVer ? input : new SemVer(input);
}
function compare($a, operator, $b) {
const a = semver($a);