Skip to content

Commit 19bb0cc

Browse files
committed
Add another usage example for StackTrace.getSync() to README
1 parent 309dbb8 commit 19bb0cc

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,21 @@ var errback = function(err) { console.log(err.message); };
2626

2727
StackTrace.get().then(callback).catch(errback);
2828
//===> Promise(Array[StackFrame], Error)
29-
//===> callback([StackFrame('func1', [], 'file.js', 203, 9), StackFrame('func2', [], 'http://localhost:3000/file.min.js', 1, 3284)])
29+
//===> callback([
30+
// StackFrame({functionName: 'func1', args: [], fileName: 'file.js', lineNumber: 203, columnNumber: 9}),
31+
// StackFrame({functionName: 'func2', args: [], fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284})
32+
//])
33+
```
34+
35+
#### You can also get a stack trace synchronously
36+
**HEADS UP:** This method does not resolve source maps or guess anonymous function names.
37+
38+
```js
39+
StackTrace.getSync();
40+
//==> [
41+
// StackFrame({functionName: 'func1', args: [], fileName: 'file.js', lineNumber: 203, columnNumber: 9}),
42+
// StackFrame({functionName: 'func2', args: [], fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284})
43+
//]
3044
```
3145

3246
#### window.onerror integration
@@ -86,7 +100,7 @@ Generate a backtrace from invocation point, then parse and enhance it.
86100
* *offline: Boolean (default: false)* - Set to `true` to prevent all network requests
87101

88102
#### `StackTrace.getSync(/*optional*/ options)` => Array[[StackFrame](https://github.com/stacktracejs/stackframe)]
89-
Generate a backtrace from invocation point, then parse it. **HEADS UP:** This method does not use source maps or guess anonymous functions.
103+
Generate a backtrace from invocation point, then parse it. This method does not use source maps or guess anonymous functions.
90104

91105
**(Optional) options: Object**
92106
* *filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`

0 commit comments

Comments
 (0)