@jfvilas/kwirth-common 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Version.d.ts +8 -0
- package/dist/Version.js +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param version1 version to check against a specifi level
|
|
4
|
+
* @param version2 level you want to compare to
|
|
5
|
+
* @returns true if version1 version is higher than version2
|
|
6
|
+
*/
|
|
7
|
+
declare const versionGreatOrEqualThan: (version1: string, version2: string) => boolean;
|
|
8
|
+
export { versionGreatOrEqualThan };
|
package/dist/Version.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2024 Julio Fernandez
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.versionGreatOrEqualThan = void 0;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param version1 version to check against a specifi level
|
|
22
|
+
* @param version2 level you want to compare to
|
|
23
|
+
* @returns true if version1 version is higher than version2
|
|
24
|
+
*/
|
|
25
|
+
const versionGreatOrEqualThan = (version1, version2) => {
|
|
26
|
+
const v1 = version1.split('.').map(Number);
|
|
27
|
+
const v2 = version2.split('.').map(Number);
|
|
28
|
+
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
|
29
|
+
const num1 = v1[i] || 0;
|
|
30
|
+
const num2 = v2[i] || 0;
|
|
31
|
+
if (num1 > num2)
|
|
32
|
+
return true;
|
|
33
|
+
else if (num1 < num2)
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
// versions are equal
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
exports.versionGreatOrEqualThan = versionGreatOrEqualThan;
|