Browse files

Update custom modules article.

  • Loading branch information...
1 parent 7b50c13 commit e4dc85c63557f7f6d9bb00b381e924a3220ec5d5 @creationix committed Jul 28, 2010
@@ -1,7 +1,7 @@
Title: Creating Custom Modules
Author: Aaron Blohowiak
Date: Tue May 18 2010 13:37:07 GMT-0500 (CDT)
-Node: v0.1.95
+Node: v0.1.102
Node implements [CommonJS Modules 1.0]( Node's [full API doc.]( explains their use thoroughly, but can be a bit tricky to get started.
@@ -40,14 +40,14 @@ The basic example on the [Node.JS Home Page]( shows you how to
When you want to use a port of a Module you use the require function like usual, but only save a reference to a member of the returned exports object:
- var puts = require('sys').puts;
+ var inspect = require('sys').inspect;
-This creates a local variable, 'puts' and assigns it to the 'puts' property of the sys module.
+This creates a local variable, 'inspect' and assigns it to the 'inspect' property of the sys module.
So now you can
- puts("hello!");
+ inspect({Hello:"World"})
-which is like sys.puts("hello!") without having to type sys.puts all the time.
+which is like `sys.inspect({Hello:"World"})` without having to type `sys.inspect` all the time.
Normal JavaScript function binding rules apply, so if you have any weirdness that you can't figure out, just import the whole module and use it like usual until you [Learn more about JavaScript Binding](
@@ -1,5 +1,4 @@
-var sys = require('sys'),
- simple = require('./simplest-module-ever-complete');
+var simple = require('./simplest-module-ever-complete');
// This will output 42
@@ -1,5 +1,4 @@
-var sys = require('sys'),
- simple = require('./simplest-module-ever');
+var simple = require('./simplest-module-ever');
// This will throw an error!

0 comments on commit e4dc85c

Please sign in to comment.