tw5-typed / modules / IModules
Interface: IModules
modules.IModules
Information about each module is kept in an object with these members:
- moduleType: type of module
- definition: object, function or string defining the module; see below
- exports: exports of the module, filled in after execution
The definition can be of several types:
- An object can be used to directly specify the exports of the module
- A function with the arguments
module,require,exportsthat returnsexports - A string function body with the same arguments
Each moduleInfo object is stored in two hashmaps: $tw.modules.titles and $tw.modules.types. The first is indexed by title and the second is indexed by type and then title
Table of contents
Properties
- applyMethods
- createClassFromModule
- createClassesFromModules
- define
- execute
- forEachModuleOfType
- getModulesByTypeAsHashmap
- titles
- types
Properties
applyMethods
• applyMethods: (moduleType: string, targetObject?: ITWModuleExports) => ITWModuleExports
Apply the exports of the modules of a particular type to a target object
Type declaration
▸ (moduleType, targetObject?): ITWModuleExports
Apply the exports of the modules of a particular type to a target object
Parameters
| Name | Type |
|---|---|
moduleType | string |
targetObject? | ITWModuleExports |
Returns
Defined in
createClassFromModule
• createClassFromModule: (moduleExports: ITWModuleExports, baseClass: () => unknown) => ITWModuleExports
Return a class created from a modules. The module should export the properties to be added to those of the optional base class
Type declaration
▸ (moduleExports, baseClass): ITWModuleExports
Return a class created from a modules. The module should export the properties to be added to those of the optional base class
Parameters
| Name | Type |
|---|---|
moduleExports | ITWModuleExports |
baseClass | () => unknown |
Returns
Defined in
createClassesFromModules
• createClassesFromModules: (moduleType: string, subType: string, baseClass: () => unknown) => Record<string, ITWModuleExports>
Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class
Type declaration
▸ (moduleType, subType, baseClass): Record<string, ITWModuleExports>
Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class
Parameters
| Name | Type |
|---|---|
moduleType | string |
subType | string |
baseClass | () => unknown |
Returns
Record<string, ITWModuleExports>
Defined in
define
• define: (moduleName: string, moduleType: string, definition: string | ITWModuleExports | TWModuleDefinitionFucntion) => void
Define a JavaScript tiddler module for later execution
Param
name of module being defined
Param
type of module
Param
module definition; see discussion above
Memberof
ITWModules
Type declaration
▸ (moduleName, moduleType, definition): void
Define a JavaScript tiddler module for later execution
Parameters
| Name | Type | Description |
|---|---|---|
moduleName | string | name of module being defined |
moduleType | string | type of module |
definition | string | ITWModuleExports | TWModuleDefinitionFucntion | module definition; see discussion above |
Returns
void
Memberof
ITWModules
Defined in
execute
• execute: (moduleName: string, moduleRoot: string) => ITWModuleExports
Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
Memberof
ITWModules
Type declaration
▸ (moduleName, moduleRoot): ITWModuleExports
Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
Parameters
| Name | Type |
|---|---|
moduleName | string |
moduleRoot | string |
Returns
Memberof
ITWModules
Defined in
forEachModuleOfType
• forEachModuleOfType: (moduleType: string, callback: (title: string, moduleExports: unknown) => void) => void
Apply a callback to each module of a particular type
Param
type of modules to enumerate
Param
function called as callback(title,moduleExports) for each module
Memberof
ITWModules
Type declaration
▸ (moduleType, callback): void
Apply a callback to each module of a particular type
Parameters
| Name | Type | Description |
|---|---|---|
moduleType | string | type of modules to enumerate |
callback | (title: string, moduleExports: unknown) => void | function called as callback(title,moduleExports) for each module |
Returns
void
Memberof
ITWModules
Defined in
getModulesByTypeAsHashmap
• getModulesByTypeAsHashmap: (moduleType: string, nameField: string) => Record<string, IModuleInfo>
Get all the modules of a particular type in a hashmap by their name field
Type declaration
▸ (moduleType, nameField): Record<string, IModuleInfo>
Get all the modules of a particular type in a hashmap by their name field
Parameters
| Name | Type |
|---|---|
moduleType | string |
nameField | string |
Returns
Record<string, IModuleInfo>
Defined in
titles
• titles: Record<string, IModuleInfo>
hashmap by module name of moduleInfo
Defined in
types
• types: Record<string, Record<string, IModuleInfo>>
hashmap by module type and then name of moduleInfo