| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -564,6 +564,9 @@ changes: | |||
| 564 | 564 | Returns an array of call site objects containing the stack of | |
| 565 | 565 | the caller function. | |
| 566 | 566 | ||
| 567 | + Unlike accessing an `error.stack`, the result returned from this API is not | ||
| 568 | + interfered with `Error.prepareStackTrace`. | ||
| 569 | + | ||
| 567 | 570 | ```mjs | |
| 568 | 571 | import { getCallSites } from 'node:util'; | |
| 569 | 572 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('node:assert'); | ||
| 5 | + const { getCallSites } = require('node:util'); | ||
| 6 | + | ||
| 7 | + // Asserts that util.getCallSites() does not invoke | ||
| 8 | + // Error.prepareStackTrace. | ||
| 9 | + | ||
| 10 | + Error.prepareStackTrace = common.mustNotCall(); | ||
| 11 | + | ||
| 12 | + const sites = getCallSites(1); | ||
| 13 | + assert.strictEqual(sites.length, 1); | ||
| 14 | + assert.strictEqual(sites[0].scriptName, __filename); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments