mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
Use template literals instead of string concatenation (#176)
This commit is contained in:
parent
e4735884c0
commit
05ff9c85a1
4 changed files with 8 additions and 8 deletions
|
@ -31,13 +31,13 @@ _global["console"] = {
|
||||||
|
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
error(...args: any[]): void {
|
error(...args: any[]): void {
|
||||||
print("ERROR: " + stringifyArgs(args));
|
print(`ERROR: ${stringifyArgs(args)}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
assert(condition: boolean, ...args: any[]): void {
|
assert(condition: boolean, ...args: any[]): void {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
throw new Error("Assertion failed: " + stringifyArgs(args));
|
throw new Error(`Assertion failed: ${stringifyArgs(args)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -181,7 +181,7 @@ function resolveModuleName(
|
||||||
function execute(fileName: string, outputCode: string): void {
|
function execute(fileName: string, outputCode: string): void {
|
||||||
util.assert(outputCode && outputCode.length > 0);
|
util.assert(outputCode && outputCode.length > 0);
|
||||||
_global["define"] = makeDefine(fileName);
|
_global["define"] = makeDefine(fileName);
|
||||||
outputCode += "\n//# sourceURL=" + fileName;
|
outputCode += `\n//# sourceURL=${fileName}`;
|
||||||
globalEval(outputCode);
|
globalEval(outputCode);
|
||||||
_global["define"] = null;
|
_global["define"] = null;
|
||||||
}
|
}
|
||||||
|
|
2
util.ts
2
util.ts
|
@ -14,7 +14,7 @@ export function log(...args: any[]): void {
|
||||||
|
|
||||||
export function assert(cond: boolean, msg = "") {
|
export function assert(cond: boolean, msg = "") {
|
||||||
if (!cond) {
|
if (!cond) {
|
||||||
throw Error("Assert fail. " + msg);
|
throw Error(`Assert fail. ${msg}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ export function prepareStackTraceWrapper(
|
||||||
|
|
||||||
export function prepareStackTrace(error: Error, stack: CallSite[]): string {
|
export function prepareStackTrace(error: Error, stack: CallSite[]): string {
|
||||||
const frames = stack.map(
|
const frames = stack.map(
|
||||||
(frame: CallSite) => "\n at " + wrapCallSite(frame).toString()
|
(frame: CallSite) => `\n at ${wrapCallSite(frame).toString()}`
|
||||||
);
|
);
|
||||||
return error.toString() + frames.join("");
|
return error.toString() + frames.join("");
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ function CallSiteToString(frame: CallSite): string {
|
||||||
functionName.indexOf("." + methodName) !==
|
functionName.indexOf("." + methodName) !==
|
||||||
functionName.length - methodName.length - 1
|
functionName.length - methodName.length - 1
|
||||||
) {
|
) {
|
||||||
line += " [as " + methodName + "]";
|
line += ` [as ${ methodName} ]`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
line += typeName + "." + (methodName || "<anonymous>");
|
line += typeName + "." + (methodName || "<anonymous>");
|
||||||
|
@ -176,7 +176,7 @@ function CallSiteToString(frame: CallSite): string {
|
||||||
addSuffix = false;
|
addSuffix = false;
|
||||||
}
|
}
|
||||||
if (addSuffix) {
|
if (addSuffix) {
|
||||||
line += " (" + fileLocation + ")";
|
line += ` (${fileLocation})`;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ function mapEvalOrigin(origin: string): string {
|
||||||
// Parse nested eval() calls using recursion
|
// Parse nested eval() calls using recursion
|
||||||
match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
|
match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
|
||||||
if (match) {
|
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
|
// Make sure we still return useful information if we didn't find anything
|
||||||
|
|
Loading…
Add table
Reference in a new issue