added nearly complete p2p implementation

This commit is contained in:
mrfry 2023-03-20 18:02:45 +01:00
parent 11dacdae64
commit 5c22f575dd
25 changed files with 14320 additions and 12563 deletions

View file

@ -389,6 +389,9 @@ function C(color?: string): string {
if (color === 'redbg') {
return '\x1b[41m'
}
if (color === 'yellowbg') {
return '\x1b[43m\x1b[30m'
}
if (color === 'bluebg') {
return '\x1b[44m'
}
@ -416,6 +419,23 @@ function C(color?: string): string {
return '\x1b[0m'
}
function logTable(table: (string | number)[][]): void {
table.forEach((row, i) => {
const rowString: string[] = []
row.forEach((cell, j) => {
const cellColor = j === 0 || i === 0 ? 'blue' : 'green'
let cellVal = ''
if (!isNaN(+cell)) {
cellVal = cell.toLocaleString()
} else {
cellVal = cell.toString()
}
rowString.push(C(cellColor) + cellVal + C())
})
Log(rowString.join('\t'))
})
}
export default {
getColoredDateString: getColoredDateString,
Log: Log,
@ -431,4 +451,5 @@ export default {
logDir: logDir,
vlogDir: vlogDir,
setLoggingDisabled: setLoggingDisabled,
logTable: logTable,
}