1 declare namespace callsites {
4 Returns the value of `this`.
6 getThis(): unknown | undefined;
9 Returns the type of `this` as a string. This is the name of the function stored in the constructor field of `this`, if available, otherwise the object's `[[Class]]` internal property.
11 getTypeName(): string | null;
14 Returns the current function.
16 getFunction(): Function | undefined;
19 Returns the name of the current function, typically its `name` property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
21 getFunctionName(): string | null;
24 Returns the name of the property of `this` or one of its prototypes that holds the current function.
26 getMethodName(): string | undefined;
29 Returns the name of the script if this function was defined in a script.
31 getFileName(): string | null;
34 Returns the current line number if this function was defined in a script.
36 getLineNumber(): number | null;
39 Returns the current column number if this function was defined in a script.
41 getColumnNumber(): number | null;
44 Returns a string representing the location where `eval` was called if this function was created using a call to `eval`.
46 getEvalOrigin(): string | undefined;
49 Returns `true` if this is a top-level invocation, that is, if it's a global object.
51 isToplevel(): boolean;
54 Returns `true` if this call takes place in code defined by a call to `eval`.
59 Returns `true` if this call is in native V8 code.
64 Returns `true` if this is a constructor call.
66 isConstructor(): boolean;
70 declare const callsites: {
72 Get callsites from the V8 stack trace API.
74 @returns An array of `CallSite` objects.
78 import callsites = require('callsites');
81 console.log(callsites()[0].getFileName());
82 //=> '/Users/sindresorhus/dev/callsites/test.js'
88 (): callsites.CallSite[];
90 // TODO: Remove this for the next major release, refactor the whole definition to:
91 // declare function callsites(): callsites.CallSite[];
92 // export = callsites;
93 default: typeof callsites;