{"name":"stack-trace","version":"1.0.0","author":{"url":"http://debuggable.com/","name":"Felix Geisendörfer","email":"felix@debuggable.com"},"license":"MIT","_id":"stack-trace@1.0.0","maintainers":[{"name":"felixge","email":"felix@debuggable.com"},{"name":"sebastianhoitz","email":"hoitz@komola.de"},{"name":"tim-smart","email":"tim@fostle.com"},{"name":"gajus","email":"gajus@gajus.com"},{"name":"niemyjski","email":"bniemyjski@gmail.com"},{"name":"kjg","email":"kevin@glowacz.info"}],"homepage":"https://github.com/felixge/node-stack-trace","bugs":{"url":"https://github.com/felixge/node-stack-trace/issues"},"dist":{"shasum":"bcdf4c2b89382ee1fdd881345a2d3f3613c3f370","tarball":"http://registry-npm.ywwl.com/stack-trace/download/stack-trace-1.0.0.tgz","fileCount":4,"integrity":"sha512-H6D7134xi6qONvh7ZHKgviXf+rd3vhGBSvebPZCaUkd8zvQ+7PtDw6CljPTe4cXWNf2IKZGNqw6VJXSb9IgBpA==","signatures":[{"sig":"MEUCIAnYvNgJQDZG09/cgmmkIfZxBjubvZZXtIMa2bUZhRGpAiEA7TY/pX3fkCZWTeRxfTcDDKqyuGQQKiWk4cw6W1gbyRI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10521,"size":4084,"noattachment":false,"key":"/stack-trace/-/stack-trace-1.0.0.tgz"},"main":"index.js","type":"module","engines":{"node":">=20.0.0"},"exports":{".":"./index.js","./package.json":"./package.json"},"gitHead":"68ba5373d4a24984dc7075240258cbbc0f797cea","scripts":{"test":"node --test","release":"git push && git push --tags && npm publish"},"_npmUser":{"name":"niemyjski","email":"bniemyjski@gmail.com"},"repository":{"url":"git://github.com/felixge/node-stack-trace.git","type":"git"},"_npmVersion":"11.12.1","description":"Get v8 stack traces as an array of CallSite objects.","directories":{},"_nodeVersion":"25.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/stack-trace_1.0.0_1777744594092_0.2399214520530173","host":"s3://npm-registry-packages-npm-production"},"readme":"# stack-trace\n\n[![NPM Version](https://img.shields.io/npm/v/stack-trace.svg)](https://www.npmjs.com/package/stack-trace)\n[![Tests](https://github.com/felixge/node-stack-trace/actions/workflows/test.yml/badge.svg)](https://github.com/felixge/node-stack-trace/actions/workflows/test.yml)\n\nGet v8 stack traces as an array of CallSite objects.\n\n## Install\n\n``` bash\nnpm install stack-trace\n```\n\n## Usage\n\nThe stack-trace module makes it easy for you to capture the current stack:\n\n```javascript\nimport { get } from 'stack-trace';\nconst trace = get();\n\nexpect(trace[0].getFileName()).toBe(__filename);\n```\n\nHowever, sometimes you have already popped the stack you are interested in,\nand all you have left is an `Error` object. This module can help:\n\n```javascript\nimport { parse } from 'stack-trace';\nconst err = new Error('something went wrong');\nconst trace = parse(err);\n\nexpect(trace[0].getFileName()).toBe(__filename);\n```\n\nPlease note that parsing the `Error#stack` property is not perfect, only\ncertain properties can be retrieved with it as noted in the API docs below.\n\n## Long stack traces\n\nWhen parsing an `err.stack` that has crossed the event loop boundary, a\n`CallSite` object is created whose `getFileName()` returns the full dashed\nseparator line from the stack, including any leading whitespace such as\nindentation. The other getter-style methods of the event loop boundary call site\nreturn `null`.\n\nHistorically this behavior was often observed together with\n[long-stack-traces](https://github.com/tlrobinson/long-stack-traces), but that package is unmaintained. This module does not depend on it and still supports parsing dashed event-loop boundary markers when\nthey are present in the stack string.\n\n## API\n\n### stackTrace.get([belowFn])\n\nReturns an array of `CallSite` objects, where element `0` is the current call\nsite.\n\nWhen passing a function on the current stack as the `belowFn` parameter, the\nreturned array will only include `CallSite` objects below this function.\n\n### stackTrace.parse(err)\n\nParses the `err.stack` property of an `Error` object into an array compatible\nwith those returned by `stackTrace.get()`. However, only the following methods\nare implemented on the returned `CallSite` objects.\n\n* getTypeName\n* getFunctionName\n* getMethodName\n* getFileName\n* getLineNumber\n* getColumnNumber\n* isNative\n\nNote: Except `getFunctionName()`, all of the above methods return exactly the\nsame values as you would get from `stackTrace.get()`. `getFunctionName()`\nis sometimes a little different, but still useful.\n\n### CallSite\n\nThe official v8 CallSite object API can be found in the [V8 stack trace API docs](https://v8.dev/docs/stack-trace-api#customizing-stack-traces). A quick\nexcerpt:\n\n> A CallSite object defines the following methods:\n>\n> * **getThis**: returns the value of this\n> * **getTypeName**: 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.\n> * **getFunction**: returns the current function\n> * **getFunctionName**: returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.\n> * **getMethodName**: returns the name of the property of this or one of its prototypes that holds the current function\n> * **getFileName**: if this function was defined in a script returns the name of the script\n> * **getLineNumber**: if this function was defined in a script returns the current line number\n> * **getColumnNumber**: if this function was defined in a script returns the current column number\n> * **getEvalOrigin**: if this function was created using a call to eval returns a CallSite object representing the location where eval was called\n> * **isToplevel**: is this a toplevel invocation, that is, is this the global object?\n> * **isEval**: does this call take place in code defined by a call to eval?\n> * **isNative**: is this call in native V8 code?\n> * **isConstructor**: is this a constructor call?\n\n## License\n\nstack-trace is licensed under the MIT license.\n","publish_time":1777744594237,"_cnpm_publish_time":1777744594237,"dist-tags":{"latest":"1.0.0"}}