Skip to content

Latest commit

 

History

History
189 lines (133 loc) · 6.53 KB

File metadata and controls

189 lines (133 loc) · 6.53 KB

Registry

Registry class for managing different classes.

Kind: global class

new Registry(config)

Create a new Registry instance.

Param Type Description
config Object Configuration object.
config.classes Object Initial set of classes.

registry.createInstance(name, args, baseClass) ⇒ Object

Create an instance of a class.

Kind: instance method of Registry
Returns: Object - An instance of the class.

Param Type Description
name string The name of the class to instantiate.
args Array The arguments to pass to the class constructor.
baseClass function The base class for validation.

registry.isValidClass(targetClass, baseClass) ⇒ boolean

Check if a class is valid.

Kind: instance method of Registry
Returns: boolean - Whether the class is valid.

Param Type Description
targetClass function The class to check.
baseClass function The base class for validation.

registry.isValidInstance(instance, baseClass) ⇒ boolean

Check if an instance is valid.

Kind: instance method of Registry
Returns: boolean - Whether the instance is valid.

Param Type Description
instance Object The instance to check.
baseClass function The base class for validation.

registry.ingest(source)

Ingest classes from a source.

Kind: instance method of Registry

Param Type Description
source Object The source object.

registry.setWith(name, targetClass, baseClass, override)

Register a class with additional validation.

Kind: instance method of Registry

Param Type Default Description
name string The name of the class.
targetClass function The class to register.
baseClass function The base class for validation.
override boolean false Whether to override existing class.

registry.set(name, targetClass, override)

Register a class.

Kind: instance method of Registry

Param Type Default Description
name string The name of the class.
targetClass function The class to register.
override boolean true Whether to override existing class.

registry.setMany(classes, override)

Register multiple classes.

Kind: instance method of Registry

Param Type Default Description
classes Object An object mapping names to classes.
override boolean false Whether to override existing classes.

registry.get(name, defaultValue) ⇒ function | null

Retrieve a class by name.

Kind: instance method of Registry
Returns: function | null - The class or null.

Param Type Default Description
name string The name of the class.
defaultValue * The default value if the class does not exist.

registry.has(name) ⇒ boolean

Check if a class exists by name.

Kind: instance method of Registry
Returns: boolean - Whether the class exists.

Param Type Description
name string The name of the class.

registry.remove(name)

Removes a specific class from the registry.

Kind: instance method of Registry

Param Type Description
name string The name of the class to be removed from the registry.

registry.removeAll()

Removes all classes from the registry.

Kind: instance method of Registry

registry.destroy()

Destroys the registry by deleting all properties of the classes object. This method ensures that all class references in the registry are cleared, potentially allowing them to be garbage collected if there are no other references to them.

Kind: instance method of Registry

Registry.get(config) ⇒ Registry

Static method to get a Registry instance.

Kind: static method of Registry
Returns: Registry - A Registry instance.

Param Type Description
config Object Configuration object or existing Registry instance.