{"id":13509191,"url":"https://github.com/stacktracejs/stacktrace-gps","last_synced_at":"2025-08-16T05:38:27.371Z","repository":{"id":20249112,"uuid":"23521670","full_name":"stacktracejs/stacktrace-gps","owner":"stacktracejs","description":"Turns partial code location into precise code location","archived":false,"fork":false,"pushed_at":"2023-01-27T12:56:48.000Z","size":9923,"stargazers_count":124,"open_issues_count":22,"forks_count":36,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-23T13:36:08.228Z","etag":null,"topics":["stacktracejs"],"latest_commit_sha":null,"homepage":"https://www.stacktracejs.com/#!/docs/stacktrace-gps","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/stacktracejs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-31T19:49:06.000Z","updated_at":"2025-04-27T00:12:41.000Z","dependencies_parsed_at":"2023-02-17T12:10:32.383Z","dependency_job_id":null,"html_url":"https://github.com/stacktracejs/stacktrace-gps","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/stacktracejs/stacktrace-gps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacktracejs%2Fstacktrace-gps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacktracejs%2Fstacktrace-gps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacktracejs%2Fstacktrace-gps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacktracejs%2Fstacktrace-gps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacktracejs","download_url":"https://codeload.github.com/stacktracejs/stacktrace-gps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacktracejs%2Fstacktrace-gps/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268684093,"owners_count":24289971,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["stacktracejs"],"created_at":"2024-08-01T02:01:04.342Z","updated_at":"2025-08-16T05:38:27.344Z","avatar_url":"https://github.com/stacktracejs.png","language":"JavaScript","readme":"stacktrace-gps - Turn partial code location into precise code location\n===================\n[![Build Status](https://img.shields.io/github/workflow/status/stacktracejs/stacktrace-gps/Continuous%20Integration/master?logo=github\u0026style=flat-square)](https://github.com/stacktracejs/stacktrace-gps/actions?query=workflow%3AContinuous+Integration+branch%3Amaster)\n[![Coverage Status](https://img.shields.io/coveralls/stacktracejs/stacktrace-gps.svg?style=flat-square)](https://coveralls.io/r/stacktracejs/stacktrace-gps?branch=master)\n[![GitHub license](https://img.shields.io/github/license/stacktracejs/stacktrace-gps.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n\nThis library accepts a code location (in the form of a [StackFrame](https://github.com/stacktracejs/stackframe)) and\nreturns a new StackFrame with a more accurate location (using [source maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)) and guessed function names.\n\nThis is primarily a browser-centric library, but can be used with node.js. See the [Offline Usage section](#offline-usage) below.\n\n## Usage\n```js\nvar stackframe = new StackFrame({fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284});\nvar callback = function myCallback(foundFunctionName) { console.log(foundFunctionName); };\n\n// Such meta. Wow\nvar errback = function myErrback(error) { console.log(StackTrace.fromError(error)); };\n\nvar gps = new StackTraceGPS();\n\n// Pinpoint actual function name and source-mapped location\ngps.pinpoint(stackframe).then(callback, errback);\n//===\u003e Promise(StackFrame({functionName: 'fun', fileName: 'file.js', lineNumber: 203, columnNumber: 9}), Error)\n\n// Better location/name information from source maps\ngps.getMappedLocation(stackframe).then(callback, errback);\n//===\u003e Promise(StackFrame({fileName: 'file.js', lineNumber: 203, columnNumber: 9}), Error)\n\n// Get function name from location information\ngps.findFunctionName(stackframe).then(callback, errback);\n//===\u003e Promise(StackFrame({functionName: 'fun', fileName: 'http://localhost:3000/file.min.js', lineNumber: 1, columnNumber: 3284}), Error)\n```\n\n### Offline Usage\nWith a bit of preparation, you can use this library offline in any environment. Any encountered fileNames not in the cache return resolved\nPromises with the original StackFrame. StackTraceGPS will make a best effort to provide as good of response with what is given and will\nfallback to the original StackFrame if nothing better could be found.\n\n```js\nvar stack = ErrorStackParser.parse(new Error('boom'));\nconsole.assert(stack[0] == new StackFrame({fileName: 'http://localhost:9999/file.min.js', lineNumber: 1, columnNumber: 32}));\n\nvar sourceCache = {'http://localhost:9999/file.min.js': 'var foo=function(){};function bar(){}var baz=eval(\"XXX\");\\n//# sourceMappingURL=file.js.map'};\nvar sourceMap = '{\"version\":3,\"sources\":[\"./file.js\"],\"sourceRoot\":\"http://localhost:4000/\",\"names\":[\"foo\",\"bar\",\"baz\",\"eval\"],\"mappings\":\"AAAA,GAAIA,KAAM,YACV,SAASC,QACT,GAAIC,KAAMC,KAAK\",\"file\":\"file.min.js\"}';\nvar sourceMapConsumerCache = {'http://localhost:4000/file.js.map': new SourceMap.SourceMapConsumer(sourceMap)};\n\nvar gps = new StackTraceGPS({offline: true, sourceCache: sourceCache, sourceMapConsumerCache: sourceMapConsumerCache});\ngps.pinpoint(stack[0]).then(function(betterStackFrame) {\n    console.assert(betterStackFrame === new StackFrame({functionName: 'bar', fileName: 'http://localhost:9999/file.js', lineNumber: 2, columnNumber: 9}));\n});\n```\n\n## Installation\n```\nnpm install stacktrace-gps\nbower install stacktrace-gps\nhttps://raw.githubusercontent.com/stacktracejs/stacktrace-gps/master/dist/stacktrace-gps.min.js\n```\n\n## API\n\n#### `new StackTraceGPS(/*optional*/ options)` =\u003e StackTraceGPS\noptions: Object\n* **sourceCache: Object (String URL : String Source)** - Pre-populate source cache to avoid network requests\n* **sourceMapConsumerCache: Object (Source Mapping URL : SourceMap.SourceMapConsumer)** - Pre-populate source cache to avoid network requests\n* **offline: Boolean (default false)** - Set to `true` to prevent all network requests\n* **ajax: Function (String URL =\u003e Promise(responseText))** - Function to be used for making X-Domain requests\n* **atob: Function (String =\u003e String)** - Function to convert base64-encoded strings to their original representation\n\n#### `.pinpoint(stackframe)` =\u003e Promise(StackFrame)\nEnhance function name and use source maps to produce a better StackFrame.\n* **stackframe** - [StackFrame](https://github.com/stacktracejs/stackframe) or like object\ne.g. {fileName: 'path/to/file.js', lineNumber: 100, columnNumber: 5}\n\n#### `.findFunctionName(stackframe)` =\u003e Promise(StackFrame)\nEnhance function name and use source maps to produce a better StackFrame.\n* **stackframe** - [StackFrame](https://github.com/stacktracejs/stackframe) or like object\n\n#### `.getMappedLocation(stackframe)` =\u003e Promise(StackFrame)\nEnhance function name and use source maps to produce a better StackFrame.\n* **stackframe** - [StackFrame](https://github.com/stacktracejs/stackframe) or like object\n\n## Browser Support\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/stacktracejs.svg)](https://saucelabs.com/u/stacktracejs)\n\nFunctions that rely on [Source Maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)\n(`pinpoint` and `getMappedLocation`) require recent browsers.\n\n## Contributing\nWant to be listed as a *Contributor*? Start with the [Contributing Guide](.github/CONTRIBUTING.md)!\n","funding_links":[],"categories":["JavaScript","Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacktracejs%2Fstacktrace-gps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacktracejs%2Fstacktrace-gps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacktracejs%2Fstacktrace-gps/lists"}