1 | stackframe
|
---|
2 | ==========
|
---|
3 | ## JS Object representation of a stack frame
|
---|
4 |
|
---|
5 | [![Build Status](https://img.shields.io/github/workflow/status/stacktracejs/stackframe/Continuous%20Integration/master?logo=github&style=flat-square)](https://github.com/stacktracejs/stackframe/actions?query=workflow%3AContinuous+Integration+branch%3Amaster)
|
---|
6 | [![Coverage Status](https://img.shields.io/coveralls/stacktracejs/stackframe.svg?style=flat-square)](https://coveralls.io/r/stacktracejs/stackframe?branch=master)
|
---|
7 | [![GitHub license](https://img.shields.io/github/license/stacktracejs/stackframe.svg?style=flat-square)](https://opensource.org/licenses/MIT)
|
---|
8 | [![dependencies](https://img.shields.io/badge/dependencies-0-green.svg?style=flat-square)](https://github.com/stacktracejs/stackframe/releases)
|
---|
9 | [![gzip size](https://img.shields.io/badge/gzipped-0.96k-green.svg?style=flat-square)](https://github.com/stacktracejs/stackframe/releases)
|
---|
10 | [![module format](https://img.shields.io/badge/module%20format-umd-lightgrey.svg?style=flat-square&colorB=ff69b4)](https://github.com/stacktracejs/stackframe/releases)
|
---|
11 | [![code of conduct](https://img.shields.io/badge/code%20of-conduct-lightgrey.svg?style=flat-square&colorB=ff69b4)](http://todogroup.org/opencodeofconduct/#stacktrace.js/me@eriwen.com)
|
---|
12 |
|
---|
13 | Underlies functionality of other modules within [stacktrace.js](https://www.stacktracejs.com).
|
---|
14 |
|
---|
15 | Written to closely resemble StackFrame representations in [Gecko](http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIException.idl#14) and [V8](https://github.com/v8/v8/wiki/Stack%20Trace%20API)
|
---|
16 |
|
---|
17 | ## Usage
|
---|
18 | ```js
|
---|
19 | // Create StackFrame and set properties
|
---|
20 | var stackFrame = new StackFrame({
|
---|
21 | functionName: 'funName',
|
---|
22 | args: ['args'],
|
---|
23 | fileName: 'http://localhost:3000/file.js',
|
---|
24 | lineNumber: 1,
|
---|
25 | columnNumber: 3288,
|
---|
26 | isEval: true,
|
---|
27 | isNative: false,
|
---|
28 | source: 'ORIGINAL_STACK_LINE'
|
---|
29 | evalOrigin: new StackFrame({functionName: 'withinEval', lineNumber: 2, columnNumber: 43})
|
---|
30 | });
|
---|
31 |
|
---|
32 | stackFrame.functionName // => "funName"
|
---|
33 | stackFrame.setFunctionName('newName')
|
---|
34 | stackFrame.getFunctionName() // => "newName"
|
---|
35 |
|
---|
36 | stackFrame.args // => ["args"]
|
---|
37 | stackFrame.setArgs([])
|
---|
38 | stackFrame.getArgs() // => []
|
---|
39 |
|
---|
40 | stackFrame.fileName // => 'http://localhost:3000/file.min.js'
|
---|
41 | stackFrame.setFileName('http://localhost:3000/file.js')
|
---|
42 | stackFrame.getFileName() // => 'http://localhost:3000/file.js'
|
---|
43 |
|
---|
44 | stackFrame.lineNumber // => 1
|
---|
45 | stackFrame.setLineNumber(325)
|
---|
46 | stackFrame.getLineNumber() // => 325
|
---|
47 |
|
---|
48 | stackFrame.columnNumber // => 3288
|
---|
49 | stackFrame.setColumnNumber(20)
|
---|
50 | stackFrame.getColumnNumber() // => 20
|
---|
51 |
|
---|
52 | stackFrame.source // => 'ORIGINAL_STACK_LINE'
|
---|
53 | stackFrame.setSource('NEW_SOURCE')
|
---|
54 | stackFrame.getSource() // => 'NEW_SOURCE'
|
---|
55 |
|
---|
56 | stackFrame.isEval // => true
|
---|
57 | stackFrame.setIsEval(false)
|
---|
58 | stackFrame.getIsEval() // => false
|
---|
59 |
|
---|
60 | stackFrame.isNative // => false
|
---|
61 | stackFrame.setIsNative(true)
|
---|
62 | stackFrame.getIsNative() // => true
|
---|
63 |
|
---|
64 | stackFrame.evalOrigin // => StackFrame({functionName: 'withinEval', lineNumber: ...})
|
---|
65 | stackFrame.setEvalOrigin({functionName: 'evalFn', fileName: 'anonymous'})
|
---|
66 | stackFrame.getEvalOrigin().getFunctionName() // => 'evalFn'
|
---|
67 |
|
---|
68 | stackFrame.toString() // => 'funName(args)@http://localhost:3000/file.js:325:20'
|
---|
69 | ```
|
---|
70 |
|
---|
71 | ## Browser Support
|
---|
72 | [![Sauce Test Status](https://saucelabs.com/browser-matrix/stacktracejs.svg)](https://saucelabs.com/u/stacktracejs)
|
---|
73 |
|
---|
74 | ## Installation
|
---|
75 | ```
|
---|
76 | npm install stackframe
|
---|
77 | bower install stackframe
|
---|
78 | https://raw.githubusercontent.com/stacktracejs/stackframe/master/dist/stackframe.min.js
|
---|
79 | ```
|
---|