本文整理匯總了TypeScript中vs/base/common/strings.repeat函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript repeat函數的具體用法?TypeScript repeat怎麽用?TypeScript repeat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了repeat函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getProcessItem
function getProcessItem(processes: any[], item: ProcessItem, indent: number): void {
const isRoot = (indent === 0);
const MB = 1024 * 1024;
let name = item.name;
if (isRoot) {
name = `${product.applicationName} main`;
}
if (name === 'window') {
const windowTitle = mapPidToWindowTitle.get(item.pid);
name = windowTitle !== undefined ? `${name} (${mapPidToWindowTitle.get(item.pid)})` : name;
}
// Format name with indent
const formattedName = isRoot ? name : `${repeat(' ', indent)} ${name}`;
const memory = process.platform === 'win32' ? item.mem : (totalmem() * (item.mem / 100));
processes.push({
cpu: Number(item.load.toFixed(0)),
memory: Number((memory / MB).toFixed(0)),
pid: Number((item.pid).toFixed(0)),
name,
formattedName,
cmd: item.cmd
});
// Recurse into children if any
if (Array.isArray(item.children)) {
item.children.forEach(child => getProcessItem(processes, child, indent + 1));
}
}
示例2: getProcessItem
function getProcessItem(mapPidToWindowTitle: Map<number, string>, processes: ProcessInfo[], item: ProcessItem, indent: number): void {
const isRoot = (indent === 0);
const MB = 1024 * 1024;
// Format name with indent
let name: string;
if (isRoot) {
name = `${product.applicationName} main`;
} else {
name = `${repeat('--', indent)} ${item.name}`;
if (item.name === 'window') {
name = `${name} (${mapPidToWindowTitle.get(item.pid)})`;
}
}
const memory = process.platform === 'win32' ? item.mem : (os.totalmem() * (item.mem / 100));
processes.push({
cpu: Number(item.load.toFixed(0)),
memory: Number((memory / MB).toFixed(0)),
pid: Number((item.pid).toFixed(0)),
name
});
// Recurse into children if any
if (Array.isArray(item.children)) {
item.children.forEach(child => getProcessItem(mapPidToWindowTitle, processes, child, indent + 1));
}
}
示例3: formatProcessItem
private formatProcessItem(mainPid: number, mapPidToWindowTitle: Map<number, string>, output: string[], item: ProcessItem, indent: number): void {
const isRoot = (indent === 0);
const MB = 1024 * 1024;
// Format name with indent
let name: string;
if (isRoot) {
name = item.pid === mainPid ? `${product.applicationName} main` : 'remote agent';
} else {
name = `${repeat(' ', indent)} ${item.name}`;
if (item.name === 'window') {
name = `${name} (${mapPidToWindowTitle.get(item.pid)})`;
}
}
const memory = process.platform === 'win32' ? item.mem : (osLib.totalmem() * (item.mem / 100));
output.push(`${pad(Number(item.load.toFixed(0)), 5, ' ')}\t${pad(Number((memory / MB).toFixed(0)), 6, ' ')}\t${pad(Number((item.pid).toFixed(0)), 6, ' ')}\t${name}`);
// Recurse into children if any
if (Array.isArray(item.children)) {
item.children.forEach(child => this.formatProcessItem(mainPid, mapPidToWindowTitle, output, child, indent + 1));
}
}
示例4:
return Object.keys(gpuFeatures).map(feature => `${feature}: ${repeat(' ', longestFeatureName - feature.length)} ${gpuFeatures[feature]}`).join('\n ');