forked from igorw/buster-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module-loader.html
40 lines (38 loc) · 1.36 KB
/
module-loader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<div id="doc-nav"></div>
<div id="doc-content">
<h1><code>buster.moduleLoader</code></h1>
<dl>
<dt>Version</dt>
<dd>0.2.1 <span class="date">(2011-08-25)</span>
</dd>
<dt>Module</dt>
<dd><code>require("buster-module-loader");</code></dd>
</dl>
<p>
Load Node modules and/or objects from inside Node modules using a simple
string identifier.
</p>
<pre><code>var moduleLoader = require("buster-module-loader");
var assert = moduleLoader.<a href="#load">load</a>("buster-assertions").assert;
// This is the same:
var assert = moduleLoader.<a href="#load">load</a>("buster-assertions#assert");</code></pre>
<div class="section">
<h2>Methods</h2>
<h3 id="load"><code>var object = moduleLoader.load(identifier)</code></h3>
<p>
Load the module/object. The hash character ("#") separates module and
object. The object may be dotted, to reach inside nested object graphs. If
the string identifies an object that is not defined, the method throws an
error.
</p>
<pre><code>try {
var mod = moduleLoader.load("module#nested.object");
} catch (e) {
console.log("Unable to load that object");
}</code></pre>
<p>
The module loader could for instance be used to load reporters:
</p>
<pre><code>var reporter = moduleLoader.load("buster-test#reporters.xUnitConsole");</code></pre>
</div>
</div>