routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
import { computeGroupsNames } from './compute-groups-names.js'
|
||||
/**
|
||||
* Throws an error if a group is specified more than once.
|
||||
*
|
||||
* @param parameters - Parameters object.
|
||||
* @param parameters.groups - The groups to check for duplicates.
|
||||
* @throws Error Will throw an error if duplicated groups are found.
|
||||
*/
|
||||
function validateNoDuplicatedGroups({ groups }) {
|
||||
let groupNames = computeGroupsNames(groups)
|
||||
let seenGroups = /* @__PURE__ */ new Set()
|
||||
let duplicatedGroups = /* @__PURE__ */ new Set()
|
||||
for (let groupName of groupNames) {
|
||||
if (seenGroups.has(groupName)) {
|
||||
duplicatedGroups.add(groupName)
|
||||
} else {
|
||||
seenGroups.add(groupName)
|
||||
}
|
||||
}
|
||||
if (duplicatedGroups.size > 0) {
|
||||
throw new Error(`Duplicated group(s): ${[...duplicatedGroups].join(', ')}`)
|
||||
}
|
||||
}
|
||||
export { validateNoDuplicatedGroups }
|
||||
Reference in New Issue
Block a user