@bhsd/common 0.5.0 → 0.6.0

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/index.d.ts CHANGED
@@ -33,7 +33,8 @@ export declare const loadScript: (src: string, globalConst: string, amd?: boolea
33
33
  export declare const getObject: (key: string) => any;
34
34
  export declare const setObject: (key: string, value: unknown) => void;
35
35
  /**
36
- * 解析版本号
37
- * @param v 版本号
36
+ * 比较版本号
37
+ * @param version 版本号
38
+ * @param baseVersion 基础版本号
38
39
  */
39
- export declare const parseVersion: (v: string) => [number, number, number];
40
+ export declare const compareVersion: (version: string, baseVersion: string) => boolean;
package/dist/index.js CHANGED
@@ -19,11 +19,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var src_exports = {};
20
20
  __export(src_exports, {
21
21
  CDN: () => CDN,
22
+ compareVersion: () => compareVersion,
22
23
  getObject: () => getObject,
23
24
  loadScript: () => loadScript,
24
25
  normalizeTitle: () => normalizeTitle,
25
26
  numToHex: () => numToHex,
26
- parseVersion: () => parseVersion,
27
27
  rawurldecode: () => rawurldecode,
28
28
  setObject: () => setObject,
29
29
  splitColors: () => splitColors
@@ -90,4 +90,8 @@ const getObject = (key) => JSON.parse(String(localStorage.getItem(key)));
90
90
  const setObject = (key, value) => {
91
91
  localStorage.setItem(key, JSON.stringify(value));
92
92
  };
93
- const parseVersion = (v) => v.split(".", 3).map(Number);
93
+ const parseVersion = (version) => version.split(".", 3).map(Number);
94
+ const compareVersion = (version, baseVersion) => {
95
+ const [major, minor] = parseVersion(version), [baseMajor, baseMinor] = parseVersion(baseVersion);
96
+ return major > baseMajor || major === baseMajor && minor >= baseMinor;
97
+ };
package/dist/index.mjs CHANGED
@@ -59,14 +59,18 @@ const getObject = (key) => JSON.parse(String(localStorage.getItem(key)));
59
59
  const setObject = (key, value) => {
60
60
  localStorage.setItem(key, JSON.stringify(value));
61
61
  };
62
- const parseVersion = (v) => v.split(".", 3).map(Number);
62
+ const parseVersion = (version) => version.split(".", 3).map(Number);
63
+ const compareVersion = (version, baseVersion) => {
64
+ const [major, minor] = parseVersion(version), [baseMajor, baseMinor] = parseVersion(baseVersion);
65
+ return major > baseMajor || major === baseMajor && minor >= baseMinor;
66
+ };
63
67
  export {
64
68
  CDN,
69
+ compareVersion,
65
70
  getObject,
66
71
  loadScript,
67
72
  normalizeTitle,
68
73
  numToHex,
69
- parseVersion,
70
74
  rawurldecode,
71
75
  setObject,
72
76
  splitColors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/common",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "author": "Bhsd",
6
6
  "files": [
@@ -13,7 +13,8 @@
13
13
  "import": "./dist/index.mjs",
14
14
  "require": "./dist/index.js"
15
15
  },
16
- "./*.cjs": "./*.cjs"
16
+ "./*.cjs": "./*.cjs",
17
+ "./package.json": "./package.json"
17
18
  },
18
19
  "types": "./dist/index.d.ts",
19
20
  "bin": {
@@ -28,6 +29,7 @@
28
29
  "devDependencies": {
29
30
  "@stylistic/eslint-plugin": "^2.11.0",
30
31
  "@stylistic/stylelint-plugin": "^3.1.1",
32
+ "@types/mocha": "^10.0.10",
31
33
  "@typescript-eslint/eslint-plugin": "^8.16.0",
32
34
  "@typescript-eslint/parser": "^8.16.0",
33
35
  "esbuild": "^0.24.0",
@@ -42,6 +44,7 @@
42
44
  "eslint-plugin-regexp": "^2.6.0",
43
45
  "eslint-plugin-unicorn": "^56.0.1",
44
46
  "http-server": "^14.1.0",
47
+ "mocha": "^10.8.2",
45
48
  "stylelint": "^16.11.0",
46
49
  "stylelint-config-recommended": "^14.0.0",
47
50
  "typescript": "^5.7.2"