Jump to content

Modules: Difference between revisions

Yagton (talk | contribs)
mNo edit summary
Lemuria (talk | contribs)
No edit summary
 
Line 1: Line 1:
Modules make it possible to reuse code for OWOT scripts, very similar to how <code>require()</code> works in [https://nodejs.org/en/ NodeJS], although in a more decentralized manner. Modules are hosted on [https://github.com/ GitHub], meaning absolutely anybody can create modules for others to use. They can be loaded using the <code>use(identifier: string)</code> function, which takes in an identifier and returns the module’s exported variable(s). Identifiers are in the format <code>user/repo@version/folder/file.js</code>; version can be either a git tag or commit id, is entirely optional (although highly recommended), and [https://semver.org/spec/v2.0.0.html semantic versioning] is fully supported.
'''Modules''' make it possible to reuse code for OWOT scripts, very similar to how <code>require()</code> works in [https://nodejs.org/en/ NodeJS], although in a more decentralized manner. Modules are hosted on [https://github.com/ GitHub], meaning absolutely anybody can create modules for others to use. They can be loaded using the <code>use(identifier: string)</code> function, which takes in an identifier and returns the module’s exported variable(s). Identifiers are in the format <code>user/repo@version/folder/file.js</code>; version can be either a git tag or commit id, is entirely optional (although highly recommended), and [https://semver.org/spec/v2.0.0.html semantic versioning] is fully supported.


<span id="how-to-use-modules"></span>
<span id="how-to-use-modules"></span>