feat: Add Deno.formatDiagnostics (#4032)

This commit is contained in:
Kitson Kelly 2020-02-25 06:48:14 +11:00 committed by GitHub
parent 5da7c7df1d
commit 2b7e28b591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 83 additions and 7 deletions

View file

@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { DiagnosticItem } from "./diagnostics.ts";
import * as dispatch from "./dispatch.ts";
import { sendSync } from "./dispatch_json.ts";
@ -7,3 +8,11 @@ export function formatError(errString: string): string {
const res = sendSync(dispatch.OP_FORMAT_ERROR, { error: errString });
return res.error;
}
/**
* Format an array of diagnostic items and return them as a single string.
* @param items An array of diagnostic items to format
*/
export function formatDiagnostics(items: DiagnosticItem[]): string {
return sendSync(dispatch.OP_FORMAT_DIAGNOSTIC, { items });
}