stacktracey
Advanced tools
Comparing version 1.0.34 to 1.0.35
{ | ||
"name": "stacktracey", | ||
"version": "1.0.34", | ||
"version": "1.0.35", | ||
"description": "Parses call stacks, reads sources and meta-information.", | ||
@@ -35,4 +35,5 @@ "main": "stacktracey", | ||
"dependencies": { | ||
"get-source": "*" | ||
"get-source": "*", | ||
"as-table": "*" | ||
} | ||
} |
@@ -12,2 +12,3 @@ # StackTracey | ||
- [x] Full sourcemap support | ||
- [x] Pretty printing | ||
@@ -120,2 +121,23 @@ ## What for | ||
## Pretty printing | ||
```javascript | ||
const prettyPrintedString = new StackTracey ().pretty | ||
``` | ||
It produces a nice compact table layout, supplied with source lines (if available). You can even replace the default NodeJS exception printer with this! | ||
``` | ||
at shouldBeVisibleInStackTrace test.js:25 const shouldBeVisibleInStackTrace = () => new StackTracey () | ||
at it test.js:100 const stack = shouldBeVisibleInStackTrace () | ||
at callFn node_modules/mocha/lib/runnable.js:326 var result = fn.call(ctx); | ||
at run node_modules/mocha/lib/runnable.js:319 callFn(this.fn); | ||
at runTest node_modules/mocha/lib/runner.js:422 test.run(fn); | ||
at node_modules/mocha/lib/runner.js:528 self.runTest(function(err) { | ||
at next node_modules/mocha/lib/runner.js:342 return fn(); | ||
at node_modules/mocha/lib/runner.js:352 next(suites.pop()); | ||
at next node_modules/mocha/lib/runner.js:284 return fn(); | ||
at <anonymous> node_modules/mocha/lib/runner.js:320 next(0); | ||
``` | ||
## Array methods | ||
@@ -151,5 +173,1 @@ | ||
``` | ||
## See also | ||
Check out a fullstack framework that utilizes all this magic for better error reporting: [Useless™](https://github.com/xpl/useless). |
@@ -9,3 +9,4 @@ "use strict"; | ||
getSource = require ('get-source'), | ||
partition = require ('./impl/partition') | ||
partition = require ('./impl/partition'), | ||
asTable = require ('as-table') | ||
@@ -167,2 +168,10 @@ /* ------------------------------------------------------------------------ */ | ||
} | ||
get pretty () { | ||
return asTable (this.withSources.map ( | ||
e => [ ('at ' + e.calleeShort.slice (0, 30)), | ||
(e.fileShort && (e.fileShort + ':' + e.line)) || '', | ||
((e.sourceLine || '').trim () || '').slice (0, 80) ])) | ||
} | ||
} | ||
@@ -169,0 +178,0 @@ |
@@ -155,2 +155,9 @@ "use strict"; | ||
}) | ||
it ('pretty printing works', function prettyTest () { | ||
const pretty = new StackTracey ().clean.pretty | ||
pretty.split ('\n')[0].should.equal ('at prettyTest test.js:158 console.log (new StackTracey ().clean.pretty)') | ||
}) | ||
}) | ||
@@ -157,0 +164,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23045
287
171
2
2
+ Addedas-table@*
+ Addedas-table@1.0.55(transitive)
+ Addedprintable-characters@1.0.42(transitive)