Skip to content

Modules

Namek edited this page May 28, 2016 · 2 revisions

Module placement

Modules are detected when there is package.json or index.js file in a subfolder. In such situation all other .js files are ignored as a single-file scripts and it's up to module implementor to load other files or modules.

Module definition

Full module definition:

module.exports = {
	onload: function() { },
	onunload: function() { },
	commands: { },
	completeArgument: function(arg) { }
	commandLineHandler: {	// this is REPL
		initContext: function() { },
		handleCompletion: function(input) { },
		handleExecution: function(input, utils, context) { },
		dispose: function() { }
	}	
}

Note: every exported property is optional.

> Read a blogpost about example filesystem module.

Other blogposts about implementing Modules:

http://www.namekdev.net/2016/04/the-state-of-importing-node-js-modules-into-java/

http://www.namekdev.net/2016/04/modules-in-the-console-take-one/

http://www.namekdev.net/2016/04/modules-in-the-console-take-two-reload/