Skip to content

Commit 9d7f154

Browse files
committed
feat: enhance version comparison methods in LoomContext
- Renamed `isVersionLowerThan` to `isVersionLessThan` for consistency. - Added new methods: `isVersionGreaterThan`, `isVersionEqual`, `isVersionGreaterThanOrEqual`, and `isVersionLessThanOrEqual` to provide comprehensive version comparison capabilities.
1 parent 82116e6 commit 9d7f154

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

src/loom.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,27 @@ export interface LoomContext<TOptionsSchema extends z.ZodType> {
55
/**
66
* Check if the version of the Unicode standard is lower than the given version.
77
*/
8-
isVersionLowerThan: (version: string) => boolean;
8+
isVersionLessThan: (version: string) => boolean;
9+
10+
/**
11+
* Check if the version of the Unicode standard is greater than the given version.
12+
*/
13+
isVersionGreaterThan: (version: string) => boolean;
14+
15+
/**
16+
* Check if the version of the Unicode standard is equal to the given version.
17+
*/
18+
isVersionEqual: (version: string) => boolean;
19+
20+
/**
21+
* Check if the version of the Unicode standard is greater than or equal to the given version.
22+
*/
23+
isVersionGreaterThanOrEqual: (version: string) => boolean;
24+
25+
/**
26+
* Check if the version of the Unicode standard is less than or equal to the given version.
27+
*/
28+
isVersionLessThanOrEqual: (version: string) => boolean;
929

1030
/**
1131
* The options.
@@ -81,8 +101,20 @@ export function createLoom<
81101
function buildLoomContext<TOptionsSchema extends z.ZodType>(options: TOptionsSchema["_input"]): LoomContext<TOptionsSchema> {
82102
return {
83103
options,
84-
isVersionLowerThan: (version) => {
104+
isVersionLessThan: (version) => {
85105
return compare(version, options.version, "<");
86106
},
107+
isVersionGreaterThan: (version) => {
108+
return compare(version, options.version, ">");
109+
},
110+
isVersionEqual: (version) => {
111+
return compare(version, options.version, "=");
112+
},
113+
isVersionGreaterThanOrEqual: (version) => {
114+
return compare(version, options.version, ">=");
115+
},
116+
isVersionLessThanOrEqual: (version) => {
117+
return compare(version, options.version, "<=");
118+
},
87119
};
88120
}

0 commit comments

Comments
 (0)