1.0.1 • Published 3 years ago
at-line v1.0.1
at-line
get calling function, filename, line-number from error stack trace
Installation
Requires nodejs.
$ npm install at-line
Usage
const {atLine} = require('at-line')
const f = () => {
const at = atLine()
console.log(at)
}
f()
// >
// { func: 'f',
// file: '/home/user/at-line/examples/test.js',
// line: '4',
// col: '14' }
API
atLine([n])
Get calling function, filename, line-number and column from stack trace at the
point of calling atLine
NOTE: This is a slow function!
Parameters
parameter | type | description |
---|---|---|
[n] | Number | optional: get result from n-th line |
Returns Object
, {func, file, line, col}
atLine.stack(err, [depth], [start])
Get error stack with processable information
Parameters
parameter | type | description |
---|---|---|
err | Error | error |
err.stack | String | stacktrace |
[depth] | Number | optional: required depth of stacktrace |
[start] | Number | optional: start with line |
Returns Array
, array of processed stack trace lines [{func, file, line, col}]
Tests
$ npm test
LICENSE
Unlicense https://unlicense.org