Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 1x 1x 1x 1x | const path = require('path')
const homedir = require('homedir')
const _ = require('lodash')
const Base58 = require('base58')
class Utils {
static capitalize(str) {
return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase()
}
static normalizeIp(ip) {
if (!ip) {
ip = '(not-running)'
}
return ip + ' '.repeat(15 - ip.length)
}
static normalizePath(filePath) {
if (path.isAbsolute(filePath)) {
return filePath
} else if (/^~\//.test(filePath)) {
return filePath.replace(/^~/, homedir())
} else {
let root = path.resolve(__dirname, '../..')
return path.resolve(root, filePath)
}
}
static sortKeys(obj) {
return _(obj).toPairs().sortBy(0).fromPairs().value()
}
static sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis))
}
static isIp(ip) {
return /\b(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b/.test('' + ip)
}
static intToBase58(v) {
return Base58.int_to_base58(v)
}
static base58ToInt(v) {
return Base58.base58_to_int(v)
}
}
module.exports = Utils
|