Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
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)
*/
Type: string
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.
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 26,292,599 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.