Installations
npm install clean-stack
Developer
sindresorhus
Developer Guide
Module System
ESM, UMD
Min. Node Version
>=14.16
Typescript Support
Yes
Node Version
14.21.3
NPM Version
9.2.0
Statistics
337 Stars
53 Commits
29 Forks
8 Watching
1 Branches
13 Contributors
Updated on 27 Jul 2024
Languages
JavaScript (97.83%)
TypeScript (2.17%)
Total Downloads
Cumulative downloads
Total Downloads
4,702,519,069
Last day
-0.7%
6,463,353
Compared to previous day
Last week
4.1%
34,668,539
Compared to previous week
Last month
15.9%
139,095,543
Compared to previous month
Last year
17.8%
1,411,148,779
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
clean-stack
Clean up error stack traces
Removes the mostly unhelpful internal Node.js entries.
Also works in Electron.
Install
1npm install clean-stack
Usage
1import cleanStack from 'clean-stack'; 2 3const error = new Error('Missing unicorn'); 4 5console.log(error.stack); 6/* 7Error: Missing unicorn 8 at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15) 9 at Module._compile (module.js:409:26) 10 at Object.Module._extensions..js (module.js:416:10) 11 at Module.load (module.js:343:32) 12 at Function.Module._load (module.js:300:12) 13 at Function.Module.runMain (module.js:441:10) 14 at startup (node.js:139:18) 15*/ 16 17console.log(cleanStack(error.stack)); 18/* 19Error: Missing unicorn 20 at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15) 21*/
API
cleanStack(stack, options?)
Returns the cleaned stack or undefined
if the given stack
is undefined
.
stack
Type: string | undefined
The stack
property of an Error
.
options
Type: object
pretty
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
basePath
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
pathFilter
Type: (path: string) => boolean
Remove the stack lines where the given function returns false
. The function receives the path part of the stack line.
1import cleanStack from 'clean-stack'; 2 3const error = new Error('Missing unicorn'); 4 5console.log(cleanStack(error.stack)); 6// Error: Missing unicorn 7// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15) 8// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/omit-me.js:1:16) 9 10const pathFilter = path => !/omit-me/.test(path); 11 12console.log(cleanStack(error.stack, {pathFilter})); 13// Error: Missing unicorn 14// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
Related
- extract-stack - Extract the actual stack of an error
- stack-utils - Captures and cleans stack traces
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 12/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/clean-stack/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/clean-stack/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 12 are checked with a SAST tool
Score
4.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to clean-stack
@esm2cjs/clean-stack
Clean up error stack traces. This is a fork of sindresorhus/clean-stack, but with CommonJS support.
modern-errors-clean
`modern-errors` plugin to clean stack traces
assert-kindof
Check native type of value and throw AssertionError if not okey. Clean stack traces. Simplicity. Built on [is-kindof][].
stack-utils
Captures and cleans stack traces