(
name: string,
{
kind,
applyFn,
compounds,
compoundsWith,
order,
}: {
kind: T
applyFn: VariantFn<T>
compoundsWith: Compounds
compounds: Compounds
order?: number
},
)
| 279 | } |
| 280 | |
| 281 | private set<T extends Variant['kind']>( |
| 282 | name: string, |
| 283 | { |
| 284 | kind, |
| 285 | applyFn, |
| 286 | compounds, |
| 287 | compoundsWith, |
| 288 | order, |
| 289 | }: { |
| 290 | kind: T |
| 291 | applyFn: VariantFn<T> |
| 292 | compoundsWith: Compounds |
| 293 | compounds: Compounds |
| 294 | order?: number |
| 295 | }, |
| 296 | ) { |
| 297 | let existing = this.variants.get(name) |
| 298 | if (existing) { |
| 299 | Object.assign(existing, { kind, applyFn, compounds }) |
| 300 | } else { |
| 301 | if (order === undefined) { |
| 302 | this.lastOrder = this.nextOrder() |
| 303 | order = this.lastOrder |
| 304 | } |
| 305 | this.variants.set(name, { |
| 306 | kind, |
| 307 | applyFn, |
| 308 | order, |
| 309 | compoundsWith, |
| 310 | compounds, |
| 311 | }) |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | private nextOrder() { |
| 316 | return this.groupOrder ?? this.lastOrder + 1 |
no test coverage detected