From 7990c5250af8a8ab0aa95e3fbdbf7da113c38048 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Tue, 24 Mar 2015 11:46:41 +0100 Subject: [PATCH] Add definitions for stack-mapper. --- CONTRIBUTORS.md | 1 + stack-mapper/stack-mapper-tests.ts | 8 ++++++ stack-mapper/stack-mapper.d.ts | 46 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 stack-mapper/stack-mapper-tests.ts create mode 100644 stack-mapper/stack-mapper.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0db9eae38..5b8a18dca 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -730,6 +730,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](sprintf/sprintf.d.ts) [sprintff](https://github.com/maritz/node-sprintff) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](sharepoint/SharePoint.d.ts) [sptypescript](http://sptypescript.codeplex.com) by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru), [Andrey Markeev](http://markeev.com) * [:link:](sqlite3/sqlite3.d.ts) [sqlite3](https://github.com/mapbox/node-sqlite3) by [Nick Malaguti](https://github.com/nmalaguti) +* [:link:](stack-mapper/stack-mapper.d.ts) [stack-mapper](https://github.com/thlorenz/stack-mapper) by [rogierschouten](https://github.com/rogierschouten) * [:link:](stampit/stampit.d.ts) [stampit](https://github.com/ericelliott/stampit) by [Vasyl Boroviak](https://github.com/koresar) * [:link:](stats/stats.d.ts) [Stats.js r12](http://github.com/mrdoob/stats.js) by [Gregory Dalton](https://github.com/gregolai) * [:link:](status-bar/status-bar.d.ts) [status-bar](https://github.com/atom/status-bar) by [vvakame](https://github.com/vvakame) diff --git a/stack-mapper/stack-mapper-tests.ts b/stack-mapper/stack-mapper-tests.ts new file mode 100644 index 000000000..98dd70ef1 --- /dev/null +++ b/stack-mapper/stack-mapper-tests.ts @@ -0,0 +1,8 @@ +/// + +import stackMapper = require("stack-mapper"); + +var map: any = {}; +var sm: stackMapper.StackMapper = stackMapper(map); +var input: stackMapper.Callsite[] = [{ filename: "boo", line: 1, column: 10 }]; +var cs: stackMapper.Callsite[] = sm.map(input); diff --git a/stack-mapper/stack-mapper.d.ts b/stack-mapper/stack-mapper.d.ts new file mode 100644 index 000000000..3426f5b9d --- /dev/null +++ b/stack-mapper/stack-mapper.d.ts @@ -0,0 +1,46 @@ +// Type definitions for stack-mapper 0.2.2 +// Project: https://github.com/thlorenz/stack-mapper +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "stack-mapper" { + + module stackMapper { + + export class StackMapper { + + /** + * Maps the trace statements of the given error stack and replaces locations + * referencing code in the generated file with the locations inside the original files. + * + * @name map + * @function + * @param {Array} array of callsite objects (see readme for details about Callsite object) + * @return {Array.} info about the error stack with adapted locations, each with the following properties + * - filename: original filename + * - line: origial line in that filename of the trace + * - column: origial column on that line of the trace + */ + public map(stack: Callsite[]): Callsite[]; + } + + export interface Callsite { + filename: string; + line: number; + column: number; + } + + } + + /** + * Returns a Stackmapper that will use the given source map to map error trace locations. + * + * @name stackMapper + * @function + * @param {Object} sourcemap source map for the generated file + * @return {StackMapper} stack mapper for the particular source map + */ + function stackMapper(sourcemap: any): stackMapper.StackMapper; + + export = stackMapper; +}