Skip to content
Browse files

more examples!

  • Loading branch information...
1 parent e350ab2 commit fd46c57c11e5954bb78ff121d89e1f5203706c98 @substack committed Oct 3, 2011
Showing with 44 additions and 2 deletions.
  1. +25 −2 README.markdown
  2. +11 −0 example/memory.js
  3. +3 −0 example/tree.js
  4. +1 −0 example/tree/lib/util.js
  5. +3 −0 example/tree/start.js
  6. +1 −0 example/tree/x.js
View
27 README.markdown
@@ -5,8 +5,8 @@ Trace the dependency graph of a javascript file using
[detective](https://github.com/substack/node-detective) and
[resolve](https://github.com/substack/node-resolve).
-example
-=======
+examples
+========
tree.js
-------
@@ -34,6 +34,29 @@ substack : node-subdeps $ node example/tree.js
substack : node-subdeps $
````
+memory.js
+---------
+
+````javascript
+var subdeps = require('../');
+var deps = subdeps.sync('/a.js', { sources : {
+ '/a.js' : "var b = require('./b');",
+ '/b.js' : "var c = require('f')",
+ '/c.js' : "var d = require('./lib/d.js')",
+ '/lib/d.js' : "var e = require('e');",
+ '/node_modules/e/index.js' : '55',
+ '/node_modules/f/beep.js' : '"boop"',
+ '/node_modules/f/package.json' : JSON.stringify({ main : "beep.js" })
+} });
+console.dir(deps);
+````
+
+output:
+
+````
+[ '/a.js', '/b.js', '/node_modules/f/beep.js' ]
+````
+
methods
=======
View
11 example/memory.js
@@ -0,0 +1,11 @@
+var subdeps = require('../');
+var deps = subdeps.sync('/a.js', { sources : {
+ '/a.js' : "var b = require('./b');",
+ '/b.js' : "var c = require('f')",
+ '/c.js' : "var d = require('./lib/d.js')",
+ '/lib/d.js' : "var e = require('e');",
+ '/node_modules/e/index.js' : '55',
+ '/node_modules/f/beep.js' : '"boop"',
+ '/node_modules/f/package.json' : JSON.stringify({ main : "beep.js" })
+} });
+console.dir(deps);
View
3 example/tree.js
@@ -0,0 +1,3 @@
+var subdeps = require('../');
+var deps = subdeps.sync(__dirname + '/tree/start.js');
+console.dir(deps);
View
1 example/tree/lib/util.js
@@ -0,0 +1 @@
+exports.sin = Math.sin;
View
3 example/tree/start.js
@@ -0,0 +1,3 @@
+var detective = require('detective');
+var util = require('./lib/util.js');
+var x = require('./x');
View
1 example/tree/x.js
@@ -0,0 +1 @@
+module.exports = 'xxx';

0 comments on commit fd46c57

Please sign in to comment.
Something went wrong with that request. Please try again.