Installations
npm install stack-utils
Developer
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
>=10
Typescript Support
No
Node Version
18.12.0
NPM Version
8.19.2
Statistics
192 Stars
94 Commits
35 Forks
4 Watching
4 Branches
15 Contributors
Updated on 21 Nov 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
4,614,791,649
Last day
-3.1%
6,052,748
Compared to previous day
Last week
4%
33,052,920
Compared to previous week
Last month
23.2%
128,826,887
Compared to previous month
Last year
11.1%
1,249,980,401
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
7
stack-utils
Captures and cleans stack traces.
Extracted from lib/stack.js
in the node-tap
project
Install
$ npm install --save stack-utils
Usage
1const StackUtils = require('stack-utils'); 2const stack = new StackUtils({cwd: process.cwd(), internals: StackUtils.nodeInternals()}); 3 4console.log(stack.clean(new Error().stack)); 5// outputs a beautified stack trace
API
new StackUtils([options])
Creates a new stackUtils
instance.
options
internals
Type: array
of RegularExpression
s
A set of regular expressions that match internal stack stack trace lines which should be culled from the stack trace.
The default is StackUtils.nodeInternals()
, this can be disabled by setting []
or appended using
StackUtils.nodeInternals().concat(additionalRegExp)
. See also ignoredPackages
.
ignoredPackages
Type: array
of string
s
An array of npm modules to be culled from the stack trace. This list will mapped to regular
expressions and merged with the internals
.
Default ''
.
cwd
Type: string
The path to the current working directory. File names in the stack trace will be shown relative to this directory.
wrapCallSite
Type: function(CallSite)
A mapping function for manipulating CallSites before processing. The first argument is a CallSite instance, and the function should return a modified CallSite. This is useful for providing source map support.
StackUtils.nodeInternals()
Returns an array of regular expressions that be used to cull lines from the stack trace that reference common Node.js internal files.
stackUtils.clean(stack, indent = 0)
Cleans up a stack trace by deleting any lines that match the internals
passed to the constructor, and shortening file names relative to cwd
.
Returns a string
with the cleaned up stack (always terminated with a \n
newline character).
Spaces at the start of each line are trimmed, indentation can be added by setting indent
to the desired number of spaces.
stack
Required
Type: string
or an array
of string
s
stackUtils.capture([limit], [startStackFunction])
Captures the current stack trace, returning an array of CallSite
s. There are good overviews of the available CallSite methods here, and here.
limit
Type: number
Default: Infinity
Limits the number of lines returned by dropping all lines in excess of the limit. This removes lines from the stack trace.
startStackFunction
Type: function
The function where the stack trace should start. The first line of the stack trace will be the function that called startStackFunction
. This removes lines from the end of the stack trace.
stackUtils.captureString([limit], [startStackFunction])
Captures the current stack trace, cleans it using stackUtils.clean(stack)
, and returns a string with the cleaned stack trace. It takes the same arguments as stackUtils.capture
.
stackUtils.at([startStackFunction])
Captures the first line of the stack trace (or the first line after startStackFunction
if supplied), and returns a CallSite
like object that is serialization friendly (properties are actual values instead of getter functions).
The available properties are:
line
:number
column
:number
file
:string
constructor
:boolean
evalOrigin
:string
native
:boolean
type
:string
function
:string
method
:string
stackUtils.parseLine(line)
Parses a string
(which should be a single line from a stack trace), and generates an object with the following properties:
line
:number
column
:number
file
:string
constructor
:boolean
evalOrigin
:string
evalLine
:number
evalColumn
:number
evalFile
:string
native
:boolean
function
:string
method
:string
License
MIT © Isaac Z. Schlueter, James Talmage
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
9 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/isaacs-makework.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/tapjs/stack-utils/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/tapjs/stack-utils/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/isaacs-makework.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/tapjs/stack-utils/isaacs-makework.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/isaacs-makework.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/tapjs/stack-utils/isaacs-makework.yml/main?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
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
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 3 are checked with a SAST tool
Score
2.6
/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 More