!CHAPTER CommonJS Modules Unfortunately, the JavaScript libraries are just in the process of being standardized. CommonJS has defined some important modules. ArangoDB implements the following * "console" is a well known logging facility to all the JavaScript developers. ArangoDB implements all of the functions described here, with the exceptions of *profile* and *count*. * "fs" provides a file system API for the manipulation of paths, directories, files, links, and the construction of file streams. ArangoDB implements most of Filesystem/A functions described here. * Modules are implemented according to Modules/1.1.1 * Packages are implemented according to Packages/1.0 !SUBSECTION ArangoDB Specific Modules A lot of the modules, however, are ArangoDB specific. These modules are described in the following chapters. !SUBSECTION Node Modules ArangoDB also support some node modules. * "assert" implements assertion and testing functions. * "buffer" implements a binary data type for JavaScript. * "path" implements functions dealing with filenames and paths. * "punycode" implements conversion functions for punycode encoding. * "querystring" provides utilities for dealing with query strings. * "stream" provides a streaming interface. * "url" has utilities for URL resolution and parsing. !SUBSECTION Node Packages The following node packages are preinstalled. * "buster-format" * "Cheerio.JS" * "coffee-script" implements a coffee-script to JavaScript compiler. ArangoDB supports the *compile* function of the package, but not the *eval* functions. * "htmlparser2" * "Sinon.JS" * "underscore" is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. !SUBSECTION require `require(path)` *require* checks if the module or package specified by *path* has already been loaded. If not, the content of the file is executed in a new context. Within the context you can use the global variable *exports* in order to export variables and functions. This variable is returned by *require*. Assume that your module file is *test1.js* and contains exports.func1 = function() { print("1"); }; exports.const1 = 1; Then you can use *require* to load the file and access the exports. unix> ./arangosh arangosh> var test1 = require("test1"); arangosh> test1.const1; 1 arangosh> test1.func1(); 1 *require* follows the specification [Modules/1.1.1](http://wiki.commonjs.org/wiki/Modules/1.1.1).