raw-stacktrace
Advanced tools
Comparing version 0.0.2 to 1.0.0
var EventEmitter = require('events').EventEmitter | ||
, traceback = require('traceback') | ||
, path = require('path') | ||
@@ -65,5 +64,11 @@ , _ = require('underscore')._ | ||
var hasCustomFormatter = !!opts.formatter; | ||
var formatter = opts.formatter || old || traceback.v8.FormatStackTrace; | ||
var rawCallSites = !opts.rawCallSites? false : !!opts.rawCallSites; | ||
var formatter; | ||
if (opts.formatter) { | ||
formatter = opts.formatter; | ||
} else { | ||
formatter = old || require('traceback').v8.FormatStackTrace; | ||
} | ||
emitter.formatter = function(fn) { | ||
@@ -70,0 +75,0 @@ hasCustomFormatter = true; |
{ | ||
"author": "Bill Casarin <bill@casarin.ca>", | ||
"author": "William Casarin <will@casarin.ca>", | ||
"name": "raw-stacktrace", | ||
"description": "Emit raw stacktraces when errors are thrown", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"repository": { | ||
@@ -7,0 +7,0 @@ "url": "" |
@@ -8,2 +8,31 @@ | ||
## How it works | ||
node-raw-stacktrace works by hooking into v8's prepareStackTrace call. v8 calls | ||
this function when code accesses the Error.stack property to render it to a | ||
string. | ||
This means that Error.stack needs to be accessed or events will not be emitted. | ||
Usually this is not an issue if it gets logged to a file or stdout, but it's | ||
something to keep in mind. | ||
## methods | ||
```js | ||
var raw = require('raw-stacktrace'); | ||
``` | ||
### var traces = raw(opts={}) | ||
Return an `EventEmitter` that emits an array of either raw or formatted | ||
CallSites. You can read about v8's [CallSite API here](http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi#Customizing_stack_traces) | ||
`opts` may contain: | ||
* `rawCallSites`: `true` if you just want the raw array of callsites, | ||
defaults to `false`. When `false`, the callsites are formatted to objects. | ||
* `formatter`: \[optional\] a `function(err, callsites)` that formats stack | ||
traces, usually returns a string but it doesn't have to. | ||
## Example | ||
@@ -35,8 +64,8 @@ | ||
isEval: false, | ||
origin: '/Users/jb55/src/coffeescript/node-raw-stacktrace/example.js', | ||
script: '/Users/jb55/src/coffeescript/node-raw-stacktrace/example.js', | ||
origin: '/Users/jb55/src/js/node-raw-stacktrace/example.js', | ||
script: '/Users/jb55/src/js/node-raw-stacktrace/example.js', | ||
fun: [Function: testError], | ||
name: 'testError', | ||
method: null, | ||
path: '/Users/jb55/src/coffeescript/node-raw-stacktrace/example.js', | ||
path: '/Users/jb55/src/js/node-raw-stacktrace/example.js', | ||
line: 11, | ||
@@ -63,2 +92,26 @@ col: 9, | ||
### License | ||
``` | ||
The MIT License (MIT) | ||
Copyright (c) 2013 William Casarin | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6104
82
1
115