Installations
npm install @devexpress/callsite-record
Score
98.1
Supply Chain
100
Quality
82
Maintenance
100
Vulnerability
100
License
Developer
inikulin
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.17.0
NPM Version
9.6.7
Statistics
157 Stars
77 Commits
13 Forks
8 Watching
8 Branches
9 Contributors
Updated on 19 Mar 2024
Languages
JavaScript (73.23%)
HTML (26.77%)
Total Downloads
Cumulative downloads
Total Downloads
7,452,282
Last day
-2.1%
22,081
Compared to previous day
Last week
-5.9%
120,629
Compared to previous week
Last month
-12.2%
572,971
Compared to previous month
Last year
676.7%
6,602,262
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
callsite-record
Create fancy log entries for errors and function call sites.
For Error:
1'use strict'; 2 3const createCallsiteRecord = require('callsite-record'); 4 5function myFunc() { 6 throw new Error('Yo!'); 7} 8 9try { 10 myFunc(); 11} 12catch(err) { 13 console.log(createCallsiteRecord({ forError: err }).renderSync()); 14} 15
⬇
For function call up in the stack:
1'use strict'; 2 3const createCallsiteRecord = require('callsite-record'); 4 5function func2 () { 6 (function func1 () { 7 console.log(createCallsiteRecord({ byFunctionName: 'func2' }).renderSync()); 8 })(); 9} 10 11func2();
⬇
Additional goodies:
- Use renderers for different output formats, e.g. to produce output in HTML.
- Use stack filter to produce clean and beautiful stacks, e.g. removing Node lib internal calls.
Install
npm install callsite-record
API
createCallsiteRecord( { forError, isCallsiteFrame, processFrameFn }) → CallsiteRecord
You can generate a callsite for any stack frame, not only the topmost one. Use the isCallsiteFrame
function to select
a frame. This function is called for each frame starting from the top. Return true
for the desired frame to generate
the callsite.
Example:
1const createCallsiteRecord = require('callsite-record'); 2 3try { 4 throw new Error("We're doomed"); 5} 6catch(err) { 7 const record = createCallsiteRecord({ forError: err }); 8}
createCallsiteRecord({ byFunctionName, typeName, processFrameFn }) → CallsiteRecord
Creates CallsiteRecord
for the function up in the call stack specified by byFunctionName
. You can optionally specify a
typeName
if the function is a method. If the function is a constructor set byFunctionName
to constructor
.
Example:
1const createCallsiteRecord = require('callsite-record'); 2 3(function func1() { 4 (function func2() { 5 (function func3() { 6 const record = createCallsiteRecord({ byFunctionName: 'func2' }); 7 })(); 8 })(); 9})();
You can specify processFrameFn
function, which will process every frame in callstack. It's usefull when you need to
enable frame processing like source-maps-support
.
Example:
1const createCallsiteRecord = require('callsite-record'); 2const wrapCallSite = require('source-map-support').wrapCallSite; 3 4try { 5 throw new Error("We're doomed"); 6} 7catch(err) { 8 const record = createCallsiteRecord({ forError: err, processFrameFn: wrapCallSite }); 9} 10 11(function func1() { 12 (function func2() { 13 (function func3() { 14 const record = createCallsiteRecord({ byFunctionName: 'func2', processFrameFn: wrapCallSite }); 15 })(); 16 })(); 17})();
CallsiteRecord
CallsiteRecord.render([renderOptions]) → Promise<String>
Renders call site record to the string.
Example:
1record.render().then(str => console.log(str));
CallsiteRecord.renderSync([renderOptions]) → String
Sync version of the CallsiteRecord.render
.
renderOptions.frameSize
Specifies the number of lines rendered above and below the call site in the code frame. Default: 5
.
Example:
1console.log(record.renderSync({ frameSize: 0 })); 2// > 12 | func1(); 3// ... 4 5console.log(record.renderSync({ frameSize: 1 })); 6// 11 |(function func2() { 7// > 12 | func1(); 8// 13 |})(); 9// ...
renderOptions.codeFrame
Specifies if code frame should be rendered. If disabled only stack will be rendered. Default: true
.
renderOptions.stack
Specifies if stack trace should be rendered in addition to the code frame. Default: true
.
renderOptions.stackFilter
Function that will be used to filter stack frames. Function accepts 2 arguments:
stackFrame
- stack entry.idx
- index of the frame.isV8StackFrame
- iftrue
thenstackFrame
is a V8 CallSite object. Otherwise it's a StackFrame object.
Default: null
.
Example:
1const sep = require('path').sep; 2 3// Remove node core lib calls from the stack trace 4record.renderSync({ stackFilter: frame => frame.getFileName().indexOf(sep) > -1 });
renderOptions.renderer
Specifies the output format of the rendering. Default: renderers.default
. You can pass your own
renderer object (example implementations) or use
one of the built-in renderers:
renderers.default
Provides ANSI-colored output as shown above.
Usage:
1const defaultRenderer = require('callsite-record').renderers.default; 2 3record.renderSync({ renderer: defaultRenderer });
renderers.noColor
Same as default
renderer but without colors.
Usage:
1const noColorRenderer = require('callsite-record').renderers.noColor; 2 3record.renderSync({ renderer: noColorRenderer });
renderers.html
Outputs HTML that can be later decorated with the CSS and embeded into the web page. Example output.
Usage:
1const htmlRenderer = require('callsite-record').renderers.html; 2 3record.renderSync({ renderer: html });
Related
- is-es2016-keyword - Determine if string is an ES2016 keyword.
- highlight-es - Highlight ECMAScript syntax for the console or any other medium.
Author
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns 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 8/22 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
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: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/inikulin/callsite-record/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/inikulin/callsite-record/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/inikulin/callsite-record/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/inikulin/callsite-record/test.yml/master?enable=pin
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
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
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 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 17 are checked with a SAST tool
Reason
31 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-2m96-9w4j-wgv7
- Warn: Project is vulnerable to: GHSA-h726-x36v-rx45
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
Score
2.8
/10
Last Scanned on 2024-11-25
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