Janet 1.6.0-da93a73 Documentation
(Other Versions: 1.5.1 1.5.0 1.4.0 1.3.1)

Module Module

Index

module/cache module/expand-path module/find module/loaders module/loading module/paths


module/cache table
Table mapping loaded module identifiers to their environments.

module/expand-path 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, template, 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
	:cur:	the current file, or (dyn :current-file)
	:dir:	the directory containing the current file
	:name:	the filename component of path, with extenion if given
	:native:	the extension used to load natives, .so or .dll
	:sys:	the system path, or (syn :syspath)

module/find 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.

module/loaders table
A table of loading method names to loading functions. This table lets require and import load many different kinds of files as module.

module/loading table
Table mapping currently loading modules to true. Used to prevent circular dependencies.

module/paths array
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.