Modules
Modules are a core feature in Filtrera, designed to enable code reuse, separation of concerns, and clarity in your scripts. A module is a Filtrera script that exposes symbols such as functions and types via the `export` statement. Other scripts can then use the `import` statement to access these exported symbols, either directly or under a chosen namespace.
Using modules offers several benefits:
- Organization: Group related logic, functions, and types together, making large scripts easier to maintain.
- Reusability: Share business rules, utilities, or type definitions across multiple scripts without duplication.
- Encapsulation: Publicly expose only what's necessary while keeping implementation details private to the module.
- Safety: Prevent naming conflicts and unintended symbol overrides by importing symbols explicitly or into a local namespace.
Filtrera itself is intentionally minimal, but various runtimes provide access to a range of standard modules, such as
"iterators"
, "maps"
, or "text"
. Which modules are available, and how to import
custom modules (including path conventions), is determined by the host or runtime environment.
To learn more about how to author and consume modules, see the articles for the
export
statement and the import
statement.
iterators | Contains functions and filters to work with iterators. |
json | Contains functions and filters to work with JSON. |
maps | Contains functions and filters to work with maps. |
math | Contains functions and filters to work with math. |
text | Contains functions and filters to work with texts. |
xml | Contains functions and filters to read and write XML. |