Permalink
Browse files

a readme and example all up in this

  • Loading branch information...
1 parent b0e8032 commit bf1f2d07af94c128a89a47db1a62dcee79dd109f @substack substack committed Jun 18, 2011
Showing with 68 additions and 0 deletions.
  1. +59 −0 README.markdown
  2. +6 −0 example/strings.js
  3. +3 −0 example/strings_src.js
View
@@ -0,0 +1,59 @@
+detective
+=========
+
+Find all calls to require() no matter how crazily nested using a proper walk of
+the AST.
+
+example
+=======
+
+strings
+-------
+
+strings_src.js:
+
+````javascript
+var a = require('a');
+var b = require('b');
+var c = require('c');
+````
+
+strings.js:
+
+````javascript
+var detective = require('../');
+var fs = require('fs');
+
+var src = fs.readFileSync(__dirname + '/strings_src.js');
+var requires = detective(src);
+console.dir(requires);
+````
+
+output:
+
+ $ node examples/strings.js
+ [ 'a', 'b', 'c' ]
+
+methods
+=======
+
+var detective = require('detective');
+
+detective(src)
+--------------
+
+Give some source body `src`, return an array of all the require()s with string
+arguments.
+
+detective.find(src)
+-------------------
+
+Give some source body `src`, return an object with "strings" and "expressions"
+arrays for each of the require() calls.
+
+The "expressions" array will contain the stringified expressions.
+
+installation
+============
+
+ npm install detective
View
@@ -0,0 +1,6 @@
+var detective = require('../');
+var fs = require('fs');
+
+var src = fs.readFileSync(__dirname + '/strings_src.js');
+var requires = detective(src);
+console.dir(requires);
View
@@ -0,0 +1,3 @@
+var a = require('a');
+var b = require('b');
+var c = require('c');

0 comments on commit bf1f2d0

Please sign in to comment.