Skip to content

Commit 9078bd7

Browse files
committed
feat: add version comparison utility
- Added `compare-versions` dependency to facilitate version comparisons. - Implemented `isVersionLowerThan` method in `LoomContext` to check if a version is lower than the specified version.
1 parent 52605a7 commit 9078bd7

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"typecheck": "tsc --noEmit"
4242
},
4343
"dependencies": {
44+
"compare-versions": "^6.1.1",
4445
"zod": "^3.24.2"
4546
},
4647
"devDependencies": {

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loom.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import { compare } from "compare-versions";
12
import { z } from "zod";
23

34
export interface LoomContext<TOptionsSchema extends z.ZodType> {
5+
/**
6+
* Check if the version of the Unicode standard is lower than the given version.
7+
*/
8+
isVersionLowerThan: (version: string) => boolean;
9+
10+
/**
11+
* The options.
12+
*/
413
options: TOptionsSchema["_input"];
514
}
615

@@ -53,6 +62,9 @@ export function createLoom<
5362
// create context for template
5463
const ctx: LoomContext<TOptionsSchema> = {
5564
options: validatedOptions,
65+
isVersionLowerThan: (version) => {
66+
return compare(version, validatedOptions.version, "<");
67+
},
5668
};
5769

5870
// generate output for each item

0 commit comments

Comments
 (0)