@fi4f/v 1.1.1
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/out/index.d.ts +17 -0
- package/out/index.js +30 -0
- package/package.json +23 -0
- package/src/index.ts +36 -0
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function Version(o?: {
|
|
2
|
+
moniker?: string;
|
|
3
|
+
major?: number;
|
|
4
|
+
minor?: number;
|
|
5
|
+
patch?: number;
|
|
6
|
+
}): Version;
|
|
7
|
+
export interface Version {
|
|
8
|
+
readonly moniker: string;
|
|
9
|
+
readonly major: number;
|
|
10
|
+
readonly minor: number;
|
|
11
|
+
readonly patch: number;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace Version {
|
|
14
|
+
function toString(a: Version): string;
|
|
15
|
+
function compare(a: Version, b: Version): number;
|
|
16
|
+
}
|
|
17
|
+
export default Version;
|
package/out/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Version = Version;
|
|
4
|
+
function Version(o) {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
return {
|
|
7
|
+
moniker: (_a = o === null || o === void 0 ? void 0 : o.moniker) !== null && _a !== void 0 ? _a : "v",
|
|
8
|
+
major: (_b = o === null || o === void 0 ? void 0 : o.major) !== null && _b !== void 0 ? _b : 0,
|
|
9
|
+
minor: (_c = o === null || o === void 0 ? void 0 : o.minor) !== null && _c !== void 0 ? _c : 0,
|
|
10
|
+
patch: (_d = o === null || o === void 0 ? void 0 : o.patch) !== null && _d !== void 0 ? _d : 0,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
(function (Version) {
|
|
14
|
+
function toString(a) {
|
|
15
|
+
return `${a.moniker} ${a.major}.${a.minor}.${a.patch}`;
|
|
16
|
+
}
|
|
17
|
+
Version.toString = toString;
|
|
18
|
+
function compare(a, b) {
|
|
19
|
+
let k;
|
|
20
|
+
if ((k = a.major - b.major) != 0)
|
|
21
|
+
return k;
|
|
22
|
+
if ((k = a.minor - b.minor) != 0)
|
|
23
|
+
return k;
|
|
24
|
+
if ((k = a.patch - b.patch) != 0)
|
|
25
|
+
return k;
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
Version.compare = compare;
|
|
29
|
+
})(Version || (exports.Version = Version = {}));
|
|
30
|
+
exports.default = Version;
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fi4f/v",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "git+https://github.com/fi4f/v.git"
|
|
7
|
+
},
|
|
8
|
+
"main": "out/index.js",
|
|
9
|
+
"types": "out/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"out",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.6.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function Version(o ?: {
|
|
2
|
+
moniker ?: string;
|
|
3
|
+
major ?: number;
|
|
4
|
+
minor ?: number;
|
|
5
|
+
patch ?: number;
|
|
6
|
+
}): Version {
|
|
7
|
+
return {
|
|
8
|
+
moniker : o?.moniker ?? "v",
|
|
9
|
+
major : o?.major ?? 0,
|
|
10
|
+
minor : o?.minor ?? 0,
|
|
11
|
+
patch : o?.patch ?? 0,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Version {
|
|
16
|
+
readonly moniker: string;
|
|
17
|
+
readonly major : number;
|
|
18
|
+
readonly minor : number;
|
|
19
|
+
readonly patch : number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export namespace Version {
|
|
23
|
+
export function toString(a: Version) {
|
|
24
|
+
return `${a.moniker} ${a.major}.${a.minor}.${a.patch}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function compare(a: Version, b: Version) {
|
|
28
|
+
let k: number;
|
|
29
|
+
if((k = a.major - b.major) != 0) return k;
|
|
30
|
+
if((k = a.minor - b.minor) != 0) return k;
|
|
31
|
+
if((k = a.patch - b.patch) != 0) return k;
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Version;
|