Browse files

Initial commit

  • Loading branch information...
0 parents commit fa8da6088a10927b8bcdbd6bc8ba9337755927f4 @tj tj committed Oct 10, 2012
Showing with 60 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +11 −0 Makefile
  3. +12 −0 Readme.md
  4. +12 −0 component.json
  5. +23 −0 index.js
2 .gitignore
@@ -0,0 +1,2 @@
+components
+build
11 Makefile
@@ -0,0 +1,11 @@
+
+build: components index.js
+ @component build --dev
+
+components:
+ @component install --dev
+
+clean:
+ rm -fr build components template.js
+
+.PHONY: clean
12 Readme.md
@@ -0,0 +1,12 @@
+
+# stack
+
+ Get a stack of `CallSite` objects
+
+## Installation
+
+ $ component install component/stack
+
+## License
+
+ MIT
12 component.json
@@ -0,0 +1,12 @@
+{
+ "name": "stack",
+ "repo": "component/stack",
+ "description": "Get a stack of CallSite objects",
+ "version": "0.0.1",
+ "keywords": ["stack", "error", "callsite", "debug"],
+ "dependencies": {},
+ "development": {},
+ "scripts": [
+ "index.js"
+ ]
+}
23 index.js
@@ -0,0 +1,23 @@
+
+/**
+ * Expose `stack()`.
+ */
+
+module.exports = stack;
+
+/**
+ * Return the stack.
+ *
+ * @return {Array}
+ * @api public
+ */
+
+function stack() {
+ var orig = Error.prepareStackTrace;
+ Error.prepareStackTrace = function(_, stack){ return stack; };
+ var err = new Error;
+ Error.captureStackTrace(err, arguments.callee);
+ var stack = err.stack;
+ Error.prepareStackTrace = orig;
+ return stack;
+}

0 comments on commit fa8da60

Please sign in to comment.