diff --git a/doc/api/module.md b/doc/api/module.md index 1d9e0d6aa11829..a7688b56ea62f0 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -317,6 +317,37 @@ isBuiltin('fs'); // true isBuiltin('wss'); // false ``` +### `module.mapCallSite(callSite)` + + + +> Stability: 1.1 - Active development + +* `callSite` {Object | Array} A [CallSite][] object or an array of CallSite objects. +* Returns: {Object | Array} The original source code location(s) for the given CallSite object(s). + +Reconstructs the original source code location from a [CallSite][] object through the source map. + +```mjs +import { mapCallSite } from 'node:module'; +import { getCallSite } from 'node:util'; + +mapCallSite(getCallSite()); // Reconstructs the original source code location for the whole stack + +mapCallSite(getCallSite()[0]); // Reconstructs the original source code location for the first frame +``` + +```cjs +const { mapCallSite } = require('node:module'); +const { getCallSite } = require('node:util'); + +mapCallSite(getCallSite()); // Reconstructs the original source code location for the whole stack + +mapCallSite(getCallSite()[0]); // Reconstructs the original source code location for the first frame +``` + ### `module.register(specifier[, parentURL][, options])`