Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
clean-stack
Advanced tools
Package description
The clean-stack npm package is designed to clean up error stack traces. It removes the noise from stack traces, making them easier to read and understand. This is particularly useful in development and production environments where error logs can become cluttered with irrelevant paths and lines. By simplifying stack traces, developers can more quickly identify the source of errors.
Cleaning stack traces
This feature allows you to clean up the stack trace of an error. The `cleanStack` function takes an error stack as input and returns a cleaner, more readable version of it. This is particularly useful for logging and error handling in applications.
const cleanStack = require('clean-stack');
const error = new Error('An error occurred!');
console.log(cleanStack(error.stack));
The 'stack-trace' package provides utilities for working with stack traces. It allows you to parse and inspect stack traces. Compared to 'clean-stack', 'stack-trace' offers more detailed manipulation and inspection capabilities but does not focus specifically on cleaning or simplifying the stack traces.
This package is used to parse JavaScript Error stack strings and extract stack frames from them. While 'error-stack-parser' focuses on parsing and extracting information from stack traces, 'clean-stack' is more about cleaning and simplifying them for better readability.
Readme
Clean up error stack traces
Removes the mostly unhelpful internal Node.js entries.
Also works in Electron.
npm install clean-stack
import cleanStack from 'clean-stack';
const error = new Error('Missing unicorn');
console.log(error.stack);
/*
Error: Missing unicorn
at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
*/
console.log(cleanStack(error.stack));
/*
Error: Missing unicorn
at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
*/
Returns the cleaned stack or undefined
if the given stack
is undefined
.
Type: string | undefined
The stack
property of an Error
.
Type: object
Type: boolean
Default: false
Prettify the file paths in the stack:
/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15
→ ~/dev/clean-stack/unicorn.js:2:15
Type: string?
Remove the given base path from stack trace file paths, effectively turning absolute paths into relative ones. It will also transform absolute file URLs into relative paths.
Example with '/Users/sindresorhus/dev/clean-stack'
as basePath
:
/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15
→ unicorn.js:2:15
FAQs
Clean up error stack traces
The npm package clean-stack receives a total of 22,418,767 weekly downloads. As such, clean-stack popularity was classified as popular.
We found that clean-stack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.