Skip to main content

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,exports that returns exports
  • 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

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
NameType
moduleTypestring
targetObject?ITWModuleExports
Returns

ITWModuleExports

Defined in

src/modules/index.d.ts:65


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
NameType
moduleExportsITWModuleExports
baseClass() => unknown
Returns

ITWModuleExports

Defined in

src/modules/index.d.ts:70


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
NameType
moduleTypestring
subTypestring
baseClass() => unknown
Returns

Record<string, ITWModuleExports>

Defined in

src/modules/index.d.ts:75


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
NameTypeDescription
moduleNamestringname of module being defined
moduleTypestringtype of module
definitionstring | ITWModuleExports | TWModuleDefinitionFucntionmodule definition; see discussion above
Returns

void

Memberof

ITWModules

Defined in

src/modules/index.d.ts:87


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
NameType
moduleNamestring
moduleRootstring
Returns

ITWModuleExports

Memberof

ITWModules

Defined in

src/modules/index.d.ts:96


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
NameTypeDescription
moduleTypestringtype of modules to enumerate
callback(title: string, moduleExports: unknown) => voidfunction called as callback(title,moduleExports) for each module
Returns

void

Memberof

ITWModules

Defined in

src/modules/index.d.ts:104


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
NameType
moduleTypestring
nameFieldstring
Returns

Record<string, IModuleInfo>

Defined in

src/modules/index.d.ts:109


titles

titles: Record<string, IModuleInfo>

hashmap by module name of moduleInfo

Defined in

src/modules/index.d.ts:114


types

types: Record<string, Record<string, IModuleInfo>>

hashmap by module type and then name of moduleInfo

Defined in

src/modules/index.d.ts:116