Class: FormatterRegistry¶
Defined in: formatters/src/registry.ts:11
Registry for formatter implementations. Allows dynamic registration and discovery of formatters.
Formatters can be registered via class constructor (preferred) or factory function. When registered via class constructor, the static getSupportedVersions() method is enforced at both compile time (via the FormatterClass type) and runtime.
Constructors¶
Constructor¶
new FormatterRegistry():
FormatterRegistry
Returns¶
FormatterRegistry
Methods¶
clear()¶
staticclear():void
Defined in: formatters/src/registry.ts:96
Clear all registered formatters (useful for testing).
Returns¶
void
get()¶
staticget(name):Formatter|undefined
Defined in: formatters/src/registry.ts:56
Get a formatter instance by name.
Parameters¶
name¶
string
Formatter identifier
Returns¶
Formatter | undefined
Formatter instance or undefined if not found
getAll()¶
staticgetAll():Formatter[]
Defined in: formatters/src/registry.ts:65
Get all registered formatters.
Returns¶
Array of formatter instances
has()¶
statichas(name):boolean
Defined in: formatters/src/registry.ts:81
Check if a formatter is registered.
Parameters¶
name¶
string
Formatter identifier
Returns¶
boolean
list()¶
staticlist():string[]
Defined in: formatters/src/registry.ts:73
List all registered formatter names.
Returns¶
string[]
Array of formatter identifiers
register()¶
Call Signature¶
staticregister(name,FormatterCtor):void
Defined in: formatters/src/registry.ts:25
Register a formatter class.
Enforces that the class implements a static getSupportedVersions() method at compile time via the FormatterClass type and at runtime via validation.
Parameters¶
name¶
string
Unique formatter identifier
FormatterCtor¶
Formatter class with static getSupportedVersions()
Returns¶
void
Throws¶
Error if the formatter is already registered
Throws¶
Error if the class lacks a static getSupportedVersions() method
Call Signature¶
staticregister(name,factory):void
Defined in: formatters/src/registry.ts:35
Register a formatter factory function.
Parameters¶
name¶
string
Unique formatter identifier
factory¶
Factory function that creates formatter instances
Returns¶
void
Throws¶
Error if the formatter is already registered
Deprecated¶
Use the class-based overload to enforce getSupportedVersions()
unregister()¶
staticunregister(name):boolean
Defined in: formatters/src/registry.ts:89
Unregister a formatter (useful for testing).
Parameters¶
name¶
string
Formatter identifier
Returns¶
boolean