clean up code in cli/js (#6611)

This commit is contained in:
Stanislav 2020-07-07 04:45:39 +03:00 committed by GitHub
parent ab4c574f52
commit 158ae0bfe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 395 additions and 354 deletions

View file

@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// Some of the code here is adapted directly from V8 and licensed under a BSD
// style license available here: https://github.com/v8/v8/blob/24886f2d1c565287d33d71e4109a53bf0b54b75c/LICENSE.v8
import * as colors from "./colors.ts";
@ -94,10 +95,10 @@ function getMethodCall(callSite: CallSite): string {
return result;
}
function getFileLocation(callSite: CallSite, isInternal = false): string {
const cyan = isInternal ? colors.gray : colors.cyan;
const yellow = isInternal ? colors.gray : colors.yellow;
const black = isInternal ? colors.gray : (s: string): string => s;
function getFileLocation(callSite: CallSite, internal = false): string {
const cyan = internal ? colors.gray : colors.cyan;
const yellow = internal ? colors.gray : colors.yellow;
const black = internal ? colors.gray : (s: string): string => s;
if (callSite.isNative()) {
return cyan("native");
}
@ -130,9 +131,9 @@ function getFileLocation(callSite: CallSite, isInternal = false): string {
return result;
}
function callSiteToString(callSite: CallSite, isInternal = false): string {
const cyan = isInternal ? colors.gray : colors.cyan;
const black = isInternal ? colors.gray : (s: string): string => s;
function callSiteToString(callSite: CallSite, internal = false): string {
const cyan = internal ? colors.gray : colors.cyan;
const black = internal ? colors.gray : (s: string): string => s;
let result = "";
const functionName = callSite.getFunctionName();
@ -164,13 +165,11 @@ function callSiteToString(callSite: CallSite, isInternal = false): string {
} else if (functionName) {
result += colors.bold(colors.italic(black(functionName)));
} else {
result += getFileLocation(callSite, isInternal);
result += getFileLocation(callSite, internal);
return result;
}
result += ` ${black("(")}${getFileLocation(callSite, isInternal)}${black(
")"
)}`;
result += ` ${black("(")}${getFileLocation(callSite, internal)}${black(")")}`;
return result;
}