mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: add util.getCallSite() API
PR-URL: https://github.com/nodejs/node/pull/54380 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
6c6a9338cb
commit
80a989f931
7 changed files with 298 additions and 0 deletions
12
lib/util.js
12
lib/util.js
|
@ -315,6 +315,17 @@ function parseEnv(content) {
|
|||
return binding.parseEnv(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the callSite
|
||||
* @param {number} frames
|
||||
* @returns {object}
|
||||
*/
|
||||
function getCallSite(frames = 10) {
|
||||
// Using kDefaultMaxCallStackSizeToCapture as reference
|
||||
validateNumber(frames, 'frames', 1, 200);
|
||||
return binding.getCallSite(frames);
|
||||
};
|
||||
|
||||
// Keep the `exports =` so that various functions can still be monkeypatched
|
||||
module.exports = {
|
||||
_errnoException,
|
||||
|
@ -329,6 +340,7 @@ module.exports = {
|
|||
format,
|
||||
styleText,
|
||||
formatWithOptions,
|
||||
getCallSite,
|
||||
getSystemErrorMap,
|
||||
getSystemErrorName,
|
||||
inherits,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue