deno/cli/js/ops/errors.ts
Nayeem Rahman 0ea6eb83a9
refactor(core/js_error): Align JSStackFrame with CallSite (#4715)
Renames and adds missing fields to JSStackFrame from CallSite. Fixes #4705.

Cleans up base changes for line and column numbers.
2020-04-13 10:54:16 -04:00

28 lines
762 B
TypeScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { DiagnosticItem } from "../diagnostics.ts";
import { sendSync } from "./dispatch_json.ts";
export function formatDiagnostics(items: DiagnosticItem[]): string {
return sendSync("op_format_diagnostic", { items });
}
export interface Location {
fileName: string;
lineNumber: number;
columnNumber: number;
}
export function applySourceMap(location: Location): Location {
const { fileName, lineNumber, columnNumber } = location;
const res = sendSync("op_apply_source_map", {
fileName,
lineNumber: lineNumber,
columnNumber: columnNumber,
});
return {
fileName: res.fileName,
lineNumber: res.lineNumber,
columnNumber: res.columnNumber,
};
}