Nucleus itself if a spec for an interface. This documents that interface.
These functions integrate with the operating system.
This is extracted from argv[0]
in C's main function.
This will be the command-line args that were passed to the application. It's
basically everything after --
(or all the args past argv[0]
in bundled
mode).
This is the full raw argv
from C without any processing.
This allows exiting the process with an optional exit code. If this is never called and the main script returns, then the process exits with 0.
Read an environment variable by name
Set an environment variable by name.
Unset an environment variable.
nucleus.envkeys(showHidden) -> array of keys
Get a list of all environment variables.
On windows there are also hidden variables which can be shown by passing true to
showHidden
.
These give access to the JavaScript runtime.
This is a string describing the JS engine being used. It can contain values
like "duktape"
, "v8"
, etc.
Compile a string into a JavaScript function. The source is wrapped in function () { ... }
and run in function mode.
TODO: should add access to other compile modes? How portable can this be between engines?
These APIs give access to the resource bundle.
Base is the base path of the resource bundle. If running from a directory it will be the directory path, if it's a zip, it will be path to the zip.
A map of versions of nucleus and it's components.
This will load a file as data. Note that data will be one byte per character so that it's binary safe, but ASCII data will be usable as a string. If you wish to decode something that's UTF-8 encoded as a unicode string, do the following trick.
var code = decodeURIComponent(escape(nucleus.readfile("myfile.js")));
If the path is not a file, data will be false
.
This iterates through a directory calling your callback with name and type for
each entry. It will return with true
if the path was a folder and false
if
not.
The type
parameter in the callback is one of "file"
, or "directory"
usually.
This is basically a combination of nucleus.readfile
and nucleus.compile
which then executes the resulting function returning the result. It's generally
used for bootstrapping an environment or module system.
Basic path-join to be used for paths to dofile
, scandir
, and readfile
.
In addition to this tiny core, various C libraries can be baked optionally into the core and exposed through sub-objects.
This exposed bindings to libuv. Full documentation can be found at api/uv.md.