Standard library

Package management

jsclass comes with a package manager that makes it really easy to load
libraries into your application on demand on all jsclass’s supported
platforms. You can tell it which file each module in your
application lives in, and what other modules it depends on, and it takes care
of resolving dependencies and loading your code for you. This means your
application code only needs to specify which objects it needs, rather than
which scripts to download in order to run.

For example, say I want to do something with the Console
module. I just need to require it, and supply a function to run once all the
requisite code has loaded:

The package system only loads what is needed to get the objects you want, and
it makes sure that each file is only downloaded once. Where possible, files
are downloaded in parallel to improve performance, but it makes sure
interdependent scripts run in the right order.

It is designed to be able to load any code from any domain, including from
libraries that have their own package systems. It does not require the files
it loads to follow any particular package format, but it can load files that
export global variables or a CommonJS module. It expects the arguments to
JS.require() to either be the names of global objects, or exported
properties of a CommonJS module. Whichever format the loaded files use,
JS.require() will yield the referenced objects as parameters to the callback
function.