{"id":17766620,"url":"https://github.com/floatdrop/node-parsetrace","last_synced_at":"2025-03-15T13:30:52.968Z","repository":{"id":12901532,"uuid":"15578623","full_name":"floatdrop/node-parsetrace","owner":"floatdrop","description":"Minimal library for parsing and printing node stacktrace","archived":false,"fork":false,"pushed_at":"2014-07-14T16:35:53.000Z","size":304,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T20:37:26.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floatdrop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-02T07:53:56.000Z","updated_at":"2025-01-02T01:10:29.000Z","dependencies_parsed_at":"2022-09-01T12:20:34.857Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/node-parsetrace","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fnode-parsetrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fnode-parsetrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fnode-parsetrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fnode-parsetrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/node-parsetrace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735797,"owners_count":20339530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-26T20:33:26.319Z","updated_at":"2025-03-15T13:30:52.959Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-parsetrace [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]\nMinimal library for parsing and printing node stacktrace. Mostly for use in [express-error-with-sources](https://github.com/floatdrop/express-error-with-sources).\n\n## Installation\n\n`npm install --save parsetrace`\n\n## Example\n\n```javascript\nvar parsetrace = require('parsetrace');\n\ntry {\n    throw new Error('My cool error');\n} catch (e) {\n    console.log(parsetrace(e, { sources: true }).json());\n}\n```\n\n## API\n\n### parsetrace(error, [options], [callback])\n\nParses stack trace from `Error`, `string` or `object`, that have `.stack` and `.message` property.\n\nIf callback is passed - all source code fetching will be async and error will be passed to it (even if `strict` is `true`).\n\n```javascript\nparsetrace(err, function(error, trace) {\n    console.log(trace.toString());\n});\n```\n\n__Options__:\n\n * `sources` - fetch source code from files, that are mentioned in stacktrace. If file can not be found or readed - sources will be fetched silently (unless you enabled `strict` option) (default: `false`)\n * `strict` - throws errors, while parsing stacktrace and fetching source code (default: `false`)\n * `contextSize` - number of lines before and after the error line (default: `3`)\n\n__Returns__ `Object` with methods described below:\n\n### json()\n\n```json\n{\n    \"error\": \"My cool error\",\n    \"frames\": [\n        {\n            \"line\": 4,\n            \"column\": 11,\n            \"function\": \"Object.\u003canonymous\u003e\",\n            \"file\": \"/full/path/to/file.js\",\n            \"source\": {\n                \"2\": { \"code\": \"\" },\n                \"3\": { \"code\": \"try {\" },\n                \"4\": { \"code\": \"    throw new Error('My cool error');\" },\n                \"5\": { \"code\": \"} catch (e) {\" },\n                \"6\": { \"code\": \"    console.log(parsetrace(e).json());\" }\n            }\n        }\n    ]\n}\n```\n\n__Returns__ stacktrace as Json string\n\n### object()\n\nFormat of object you can see in `json()` section.\n\n__Returns__ stacktrace as Object\n\n### toString([options])\n\n__Options__:\n\n * `excludeSources` - if stacktrace was parsed with sources, this will exclude them from output (default: `false`)\n\n__Returns__ stacktrace as NodeJS formatted stacktracke string.\n\n\n[npm-url]: https://npmjs.org/package/parsetrace\n[npm-image]: https://badge.fury.io/js/parsetrace.png\n\n[travis-url]: http://travis-ci.org/floatdrop/node-parsetrace\n[travis-image]: https://secure.travis-ci.org/floatdrop/node-parsetrace.png?branch=master\n\n[depstat-url]: https://david-dm.org/floatdrop/node-parsetrace\n[depstat-image]: https://david-dm.org/floatdrop/node-parsetrace.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fnode-parsetrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fnode-parsetrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fnode-parsetrace/lists"}