[Pkg-javascript-commits] [node-detective] 04/119: a readme and example all up in this

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:44:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-detective.

commit bf1f2d07af94c128a89a47db1a62dcee79dd109f
Author: James Halliday <mail at substack.net>
Date:   Fri Jun 17 18:10:38 2011 -0700

    a readme and example all up in this
---
 README.markdown        | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 example/strings.js     |  6 +++++
 example/strings_src.js |  3 +++
 3 files changed, 68 insertions(+)

diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..29604d4
--- /dev/null
+++ b/README.markdown
@@ -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
diff --git a/example/strings.js b/example/strings.js
new file mode 100644
index 0000000..b9cc58f
--- /dev/null
+++ b/example/strings.js
@@ -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);
diff --git a/example/strings_src.js b/example/strings_src.js
new file mode 100644
index 0000000..88d0832
--- /dev/null
+++ b/example/strings_src.js
@@ -0,0 +1,3 @@
+var a = require('a');
+var b = require('b');
+var c = require('c');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-detective.git



More information about the Pkg-javascript-commits mailing list