/
call-site.ts
119 lines (104 loc) · 3.1 KB
/
call-site.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* @file Interfaces - CallSite
* @module errnode/interfaces/CallSite
*/
import type { Fn, Nullable, Optional } from '@flex-development/tutils'
/**
* Object representing a stack frame.
*
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
*/
interface CallSite {
/**
* Returns the current column number of the script the function was defined
* in.
*
* @return {Nullable<number>} Current column number or `null`
*/
getColumnNumber(): Nullable<number>
/**
* Returns a string representing the location where `eval` was called if the
* current function was created using a call to `eval`.
*
* @return {Optional<string>} Location `eval` was called or `undefined`
*/
getEvalOrigin(): Optional<string>
/**
* Returns the name of the script containing the current function if the
* function was defined in a script.
*
* @return {Optional<string>} Parent script name or `undefined`
*/
getFileName(): Optional<string>
/**
* Returns the current function.
*
* @return {Optional<Fn>} Current function or `undefined`
*/
getFunction(): Optional<Fn>
/**
* Returns the name of the current function, typically its `name` property.
*
* If a `name` property is not available, an attempt is made to infer a name
* from the function’s context.
*
* @return {Nullable<Fn['name']>} Current function name or `null`
*/
getFunctionName(): Nullable<Fn['name']>
/**
* Returns the current line number of the script the function was defined in.
*
* @return {Nullable<number>} Current line number or `null`
*/
getLineNumber(): Nullable<number>
/**
* Returns the name of the `this` property or one of its prototypes that holds
* the current function.
*
* @return {Nullable<string>} Property containing current function or `null`
*/
getMethodName(): Nullable<string>
/**
* Returns the value of `this`.
*
* @template T - `this` type
*
* @return {T} Value of `this`
*/
getThis<T = unknown>(): T
/**
* 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.
*
* @return {Nullable<string>} Type of `this` as a string or `null`
*/
getTypeName(): Nullable<string>
/**
* Returns a boolean indicating if the current call is a constructor call.
*
* @return {boolean} `true` if call is constructor call
*/
isConstructor(): boolean
/**
* Returns a boolean indicating if the current call took place in code defined
* by a call to `eval`.
*
* @return {boolean} `true` if call takes place in code defined by `eval`
*/
isEval(): boolean
/**
* Returns a boolean indicating if the current call is in native V8 code.
*
* @return {boolean} `true` if call is in native V8 code
*/
isNative(): boolean
/**
* Returns a boolean indicating the current call is a top-level invocation.
*
* @return {boolean} `true` if call is top-level invocation
*/
isToplevel(): boolean
}
export type { CallSite as default }