Janet 1.0.0-dev Documentation

Module Module

Index

module/*headerpath* module/*syspath* module/cache module/find module/loaders module/loading module/paths


module/*headerpath* var (string)
The path where the janet headers are installed. Useful for building native modules or compiling code at runtime.

module/*syspath* var (string)
The path where globally installed libraries are located. The default is set at build time and is /usr/local/lib/janet on linux/posix, and on Windows is C:/Janet/Library.

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

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. The following substitutions are preformed on each path. :sys: becomes module/*syspath*, :name: becomes the last part of the module name after the last /, and :all: is the module name literally. :native: becomes the dynamic library file extension, usually dll or so. 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.