Skip to content

Commit 87954e5

Browse files
committed
refactor: 💡 createTag changed to tagBuilder
1 parent 36de430 commit 87954e5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

‎packages/core/src/internal/tag.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const TAG = '@sirutils/core' as const
1+
import { tagBuilder } from '../utils/tags'
22

3-
export const createTag = <const T>(str: T) => `${TAG}.${str}` as TagMapper<T>
4-
5-
export type TagMapper<T> = T extends string ? `${typeof TAG}.${T}` : null
3+
export const createTag = tagBuilder('@sirutils/core')

‎packages/core/src/utils/tags.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const tagBuilder = <const T>(tag: T) => {
2+
return <const S>(str: S) => `${tag}.${str}` as TagMapper<S, T>
3+
}
4+
5+
export type TagMapper<S, T> = T extends string ? (S extends string ? `${T}.${S}` : null) : null

0 commit comments

Comments
 (0)