Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extract-stack

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-stack

Extract the actual stack of an error

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
403K
decreased by-43.23%
Maintainers
1
Weekly downloads
 
Created
Source

extract-stack Build Status

Extract the actual stack of an error

Install

$ npm install --save extract-stack

Usage

const extractStack = require('extract-stack');
const error = new Error('Missing unicorn');

console.log(error.stack);
/*
Error: Missing unicorn
    at Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)
    at Module._compile (module.js:409:26)
    at Module.load (module.js:343:32)
    at startup (node.js:139:18)
*/

console.log(extractStack(error));
/*
    at Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)
    at Module._compile (module.js:409:26)
    at Module.load (module.js:343:32)
    at startup (node.js:139:18)
*/

console.log(extractStack.lines(error));
/*
[
	'Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)'
	'Module._compile (module.js:409:26)'
	'Module.load (module.js:343:32)'
	'startup (node.js:139:18)'
]
*/

API

It gracefully handles cases where the stack is undefined or empty and returns an empty string.

extractStack(input)

Returns the actual stack part of the error stack.

extractStack.lines(input)

Returns the stack lines of the error stack without the noise as an Array.

input

Type: Error string

Either an Error or the .stack of an Error.

  • clean-stack - Clean up error stack traces

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 24 Mar 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc