Janet 1.27.0-01aab66 Documentation
(Other Versions:
1.26.0
1.25.1
1.24.0
1.23.0
1.22.0
1.21.0
1.20.0
1.19.0
1.18.1
1.17.1
1.16.1
1.15.0
1.13.1
1.12.2
1.11.1
1.10.1
1.9.1
1.8.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.1
)
Module Module
Index
module/add-paths module/cache module/expand-path module/find module/loaders module/loading module/paths module/value
function (module/add-paths ext loader)
Add paths to `module/paths` for a given loader such that the generated paths behave like other module types, including relative imports and syspath imports. `ext` is the file extension to associate with this module type, including the dot. `loader` is the keyword name of a loader in `module/loaders`. Returns the modified `module/paths`.Community Examples / source
table module/cache
A table, mapping loaded module identifiers to their environments.Community Examples / source
cfunction (module/expand-path path template)
Expands a path template as found in `module/paths` for `module/find`. This takes in a path (the argument to require) and a template string, to expand the path to a path that can be used for importing files. The replacements are as follows: * :all: -- the value of path verbatim. * :@all: -- Same as :all:, but if `path` starts with the @ character, the first path segment is replaced with a dynamic binding `(dyn <first path segment as keyword>)`. * :cur: -- the current file, or (dyn :current-file) * :dir: -- the directory containing the current file * :name: -- the name component of path, with extension if given * :native: -- the extension used to load natives, .so or .dll * :sys: -- the system path, or (dyn :syspath)Community Examples / source
function (module/find path)
Try to match a module or path name from the patterns in `module/paths`. Returns a tuple (fullpath kind) where the kind is one of :source, :native, or :image if the module is found, otherwise a tuple with nil followed by an error message.Community Examples / source
table module/loaders
A table of loading method names to loading functions. This table lets `require` and `import` load many different kinds of files as modules.Community Examples / source
table module/loading
A table, mapping currently loading modules to true. Used to prevent circular dependencies.Community Examples / source
array module/paths
The list of paths to look for modules, templated for `module/expand-path`. Each element is a two-element tuple, containing the path template and a keyword :source, :native, or :image indicating how `require` should load files found at these paths. A tuple can also contain a third element, specifying a filter that prevents `module/find` from searching that path template if the filter doesn't match the input path. The filter can be a string or a predicate function, and is often a file extension, including the period.Community Examples / source
function (module/value module sym &opt private)
Given a module table, get the value bound to a symbol `sym`. If `private` is truthy, will also resolve private module symbols. If no binding is found, will return nil.Community Examples / source