Socket
Socket
Sign inDemoInstall

at-line

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    at-line

get calling function, filename, line-number from error stack trace


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
6.84 kB
Created
Weekly downloads
 

Readme

Source

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

parametertypedescription
[n]Numberoptional: get result from n-th line

Returns Object, {func, file, line, col}

atLine.stack(err, [depth], [start])

Get error stack with processable information

Parameters

parametertypedescription
errErrorerror
err.stackStringstacktrace
[depth]Numberoptional: required depth of stacktrace
[start]Numberoptional: start with line

Returns Array, array of processed stack trace lines [{func, file, line, col}]

Tests

$ npm test

LICENSE

Unlicense https://unlicense.org

Keywords

FAQs

Last updated on 07 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc