1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

Use template literals instead of string concatenation (#176)

This commit is contained in:
kizerkizer 2018-06-10 18:31:24 -05:00 committed by Ryan Dahl
parent fe9ea6dcf8
commit 6d4135f437
4 changed files with 8 additions and 8 deletions

View file

@ -31,13 +31,13 @@ _global["console"] = {
// tslint:disable-next-line:no-any
error(...args: any[]): void {
print("ERROR: " + stringifyArgs(args));
print(`ERROR: ${stringifyArgs(args)}`);
},
// tslint:disable-next-line:no-any
assert(condition: boolean, ...args: any[]): void {
if (!condition) {
throw new Error("Assertion failed: " + stringifyArgs(args));
throw new Error(`Assertion failed: ${stringifyArgs(args)}`);
}
}
};

View file

@ -181,7 +181,7 @@ function resolveModuleName(
function execute(fileName: string, outputCode: string): void {
util.assert(outputCode && outputCode.length > 0);
_global["define"] = makeDefine(fileName);
outputCode += "\n//# sourceURL=" + fileName;
outputCode += `\n//# sourceURL=${fileName}`;
globalEval(outputCode);
_global["define"] = null;
}

View file

@ -14,7 +14,7 @@ export function log(...args: any[]): void {
export function assert(cond: boolean, msg = "") {
if (!cond) {
throw Error("Assert fail. " + msg);
throw Error(`Assert fail. ${msg}`);
}
}

View file

@ -53,7 +53,7 @@ export function prepareStackTraceWrapper(
export function prepareStackTrace(error: Error, stack: CallSite[]): string {
const frames = stack.map(
(frame: CallSite) => "\n at " + wrapCallSite(frame).toString()
(frame: CallSite) => `\n at ${wrapCallSite(frame).toString()}`
);
return error.toString() + frames.join("");
}
@ -162,7 +162,7 @@ function CallSiteToString(frame: CallSite): string {
functionName.indexOf("." + methodName) !==
functionName.length - methodName.length - 1
) {
line += " [as " + methodName + "]";
line += ` [as ${ methodName} ]`;
}
} else {
line += typeName + "." + (methodName || "<anonymous>");
@ -176,7 +176,7 @@ function CallSiteToString(frame: CallSite): string {
addSuffix = false;
}
if (addSuffix) {
line += " (" + fileLocation + ")";
line += ` (${fileLocation})`;
}
return line;
}
@ -265,7 +265,7 @@ function mapEvalOrigin(origin: string): string {
// Parse nested eval() calls using recursion
match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
if (match) {
return "eval at " + match[1] + " (" + mapEvalOrigin(match[2]) + ")";
return `eval at ${match[1]} (${mapEvalOrigin(match[2])})`;
}
// Make sure we still return useful information if we didn't find anything