callsites
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Callsites is an npm package built for JavaScript applications that makes it possible to retrieve callsites (a location in the program's source code where a given function is invoked) from the V8 stack trace API. It forms a crucial part of debugging JavaScript code, as it provides a vast range of information about function invocations including their names, current line numbers, column numbers, script origins, and much more.
Using callsites in your JavaScript application is fairly straightforward. You'll first need to install the package using npm with the command npm install callsites
. After installation, you can import it into your file with the statement import callsites from 'callsites'
and then use it by invoking the function 'callsites()' in your program. For example:
import callsites from 'callsites';
function exampleFunction() {
console.log(callsites()[0].getFileName());
// This will output the file name of the script where the function was invoked
}
exampleFunction();
The callsites documentation is available in the package's README file on its GitHub repository, accessible through https://github.com/sindresorhus/callsites
. The README file provides a comprehensive overview of the package, its installation, and usage guidelines. It also details the API, which outlines the methods available for a callsite object, such as getThis
, getTypeName
, getFunctionName
, getFileName
, and more. For more in-depth understanding of the V8 stack trace API which callsites is built upon, refer to the V8 official documentation at https://v8.dev/docs/stack-trace-api
.