Skip to main content

IModules

tw5-typed


tw5-typed / modules / IModules

Interface: IModules

Defined in: src/modules/index.d.ts:52

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

Properties

applyMethods()

applyMethods: (moduleType, targetObject?) => ITWModuleExports

Defined in: src/modules/index.d.ts:54

Apply the exports of the modules of a particular type to a target object

Parameters

moduleType

string

targetObject?

ITWModuleExports

Returns

ITWModuleExports


createClassesFromModules()

createClassesFromModules: (moduleType, subType, baseClass) => Record<string, ITWModuleExports>

Defined in: src/modules/index.d.ts:64

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

moduleType

string

subType

string

baseClass

() => unknown

Returns

Record<string, ITWModuleExports>


createClassFromModule()

createClassFromModule: (moduleExports, baseClass) => ITWModuleExports

Defined in: src/modules/index.d.ts:59

Return a class created from a modules. The module should export the properties to be added to those of the optional base class

Parameters

moduleExports

ITWModuleExports

baseClass

() => unknown

Returns

ITWModuleExports


define()

define: (moduleName, moduleType, definition) => void

Defined in: src/modules/index.d.ts:76

Define a JavaScript tiddler module for later execution

Parameters

moduleName

string

name of module being defined

moduleType

string

type of module

definition

module definition; see discussion above

string | ITWModuleExports | TWModuleDefinitionFucntion

Returns

void

Memberof

ITWModules


execute()

execute: (moduleName, moduleRoot) => ITWModuleExports

Defined in: src/modules/index.d.ts:85

Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'

Parameters

moduleName

string

moduleRoot

string

Returns

ITWModuleExports

Memberof

ITWModules


forEachModuleOfType()

forEachModuleOfType: (moduleType, callback) => void

Defined in: src/modules/index.d.ts:93

Apply a callback to each module of a particular type

Parameters

moduleType

string

type of modules to enumerate

callback

(title, moduleExports) => void

function called as callback(title,moduleExports) for each module

Returns

void

Memberof

ITWModules


getModulesByTypeAsHashmap()

getModulesByTypeAsHashmap: (moduleType, nameField) => Record<string, IModuleInfo>

Defined in: src/modules/index.d.ts:98

Get all the modules of a particular type in a hashmap by their name field

Parameters

moduleType

string

nameField

string

Returns

Record<string, IModuleInfo>


titles

titles: Record<string, IModuleInfo>

Defined in: src/modules/index.d.ts:103

hashmap by module name of moduleInfo


types

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

Defined in: src/modules/index.d.ts:105

hashmap by module type and then name of moduleInfo