Skip to content

Commit 46a9c6c

Browse files
committed
change processClassGroups() to createClassMap()
1 parent b3a368b commit 46a9c6c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/class-utils.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ClassGroupId, Config, ClassGroup, ClassValidator } from './types'
22

3-
interface ClassPartObject {
3+
export interface ClassPartObject {
44
nextPart: Record<string, ClassPartObject>
55
validators: ClassValidatorObject[]
66
classGroupId?: ClassGroupId
@@ -14,12 +14,7 @@ interface ClassValidatorObject {
1414
const CLASS_PART_SEPARATOR = '-'
1515

1616
export function createClassUtils(config: Config) {
17-
const classMap: ClassPartObject = {
18-
nextPart: {},
19-
validators: [],
20-
}
21-
22-
processClassGroups(config, classMap)
17+
const classMap = createClassMap(config)
2318

2419
function getClassGroupId(className: string) {
2520
const classParts = className.split(CLASS_PART_SEPARATOR)
@@ -69,10 +64,20 @@ function getGroupRecursive(
6964
return classPartObject.validators.find(({ validator }) => validator(classRest))?.classGroupId
7065
}
7166

72-
function processClassGroups(config: Config, classMap: ClassPartObject) {
67+
/**
68+
* Exported for testing only
69+
*/
70+
export function createClassMap(config: Config) {
71+
const classMap: ClassPartObject = {
72+
nextPart: {},
73+
validators: [],
74+
}
75+
7376
Object.entries(config.classGroups).forEach(([classGroupId, classGroup]) => {
7477
processClassesRecursively(classGroup, classMap, classGroupId)
7578
})
79+
80+
return classMap
7681
}
7782

7883
function processClassesRecursively(

0 commit comments

Comments
 (0)