-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.d.ts
More file actions
63 lines (50 loc) · 1.79 KB
/
index.d.ts
File metadata and controls
63 lines (50 loc) · 1.79 KB
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
declare const extractStack: {
/**
Extract the actual stack of an error.
It gracefully handles cases where the stack is undefined or empty and returns an empty string.
@param error - Either an `Error` or the `.stack` of an `Error`.
@returns The actual stack part of the error stack.
@example
```
import extractStack from 'extract-stack';
const error = new Error('Missing unicorn');
console.log(error.stack);
Error: Missing unicorn
// at Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)
// at Module._compile (module.js:409:26)
// at Module.load (module.js:343:32)
// at startup (node.js:139:18)
console.log(extractStack(error));
// at Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)
// at Module._compile (module.js:409:26)
// at Module.load (module.js:343:32)
// at startup (node.js:139:18)
```
*/
(error: Error | string | undefined): string;
/**
Extract the actual stack of an error as an array of lines.
@param error - Either an `Error` or the `.stack` of an `Error`.
@returns The stack lines of the error stack without the noise.
@example
```
import extractStack from 'extract-stack';
const error = new Error('Missing unicorn');
console.log(error.stack);
Error: Missing unicorn
// at Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)
// at Module._compile (module.js:409:26)
// at Module.load (module.js:343:32)
// at startup (node.js:139:18)
console.log(extractStack.lines(error));
// [
// 'Object.<anonymous> (/Users/sindresorhus/dev/extract-stack/unicorn.js:2:15)'
// 'Module._compile (module.js:409:26)'
// 'Module.load (module.js:343:32)'
// 'startup (node.js:139:18)'
// ]
```
*/
lines(error: Error | string | undefined): string[];
};
export default extractStack;