本文整理汇总了TypeScript中colors/safe.red函数的典型用法代码示例。如果您正苦于以下问题:TypeScript red函数的具体用法?TypeScript red怎么用?TypeScript red使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了red函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: write
write(log: string) {
if (this.isEnabled) {
let logJson = JSON.parse(log);
let time = new Date(logJson.time);
let timestamp = `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}.${time.getMilliseconds()}`;
switch (logJson.eventType) {
case 'IncomingServiceRequest':
console.log(`[${colors.gray(timestamp)}]: ${colors.magenta('Incoming')} (${colors.magenta(logJson.requestMethod + ':' + logJson.requestUri)}) -> ${colors.cyan(logJson.operationName)}: ${logJson.responseStatusCode >= 200 && logJson.responseStatusCode < 400 ? colors.green('SUCCESS') : colors.red('FAILURE')} (${logJson.latencyMs}ms)`);
break;
case 'OutgoingServiceRequest':
let host: string = logJson.hostname;
if (host.includes('HostName')) {
// Otherwise use HostName for host if available
host = host
.split(';')
.filter((part: string): boolean => part.startsWith('HostName'))
.reduce((acc: string, val: string): string => val.split('=')[1], host);
}
console.log(`[${colors.gray(timestamp)}]: ${colors.magenta('Outgoing')} ${colors.magenta(logJson.context)} => (${colors.magenta(logJson.operationName)}) -> ${colors.cyan(host)}: ${logJson.succeeded ? colors.green('SUCCESS') : colors.red('FAILURE')} (${logJson.latencyMs}ms)`);
break;
case 'Exception':
console.log(`[${colors.gray(timestamp)}]: ${colors.red('Exception')}:\n${colors.red(logJson.errorDetails)}`);
break;
}
}
}
示例2: printBalance
await printBalance(async (balance) => {
const amt = parseFloat(args[1]);
const address = args[2];
if (isNaN(amt)) {
console.log(red('Must provide a valid number with maximum of 6 digits ie 10.356784'));
process.exit(1);
}
if (!address) {
console.log(red('Must provide a valid recipient address'));
process.exit(1);
}
if (amt > balance) {
console.log(red(`You don't have enough ${MOSAIC_NAME} to send`));
process.exit(1);
}
try {
const preTransaction = await prepareTransfer(address, amt);
const xemFee = (preTransaction.fee / 1e6).toString();
console.log(white('Transaction Details: \n'));
console.log(`Recipient: ${yellow(address)}\n`);
console.log(`${MOSAIC_NAME} to send: ${yellow(amt.toString())}\n`);
console.log(`XEM Fee: ${yellow(xemFee)}\n\n`);
console.log(`${white('Would you like to proceed?\n')}`);
prompt.message = white(`${MOSAIC_NAME} Transfer`);
prompt.start();
prompt.get({
properties: {
confirmation: {
description: yellow('Proceed? ( y/n )')
}
}
}, async (_, result) => {
if (result.confirmation.toLowerCase() === 'y' || result.confirmation.toLowerCase() === 'yes') {
try {
const result = await sendMosaic(address, amt, selectedAccount);
console.log(result);
console.log('\n\n');
console.log(white('Transaction successfully announced to the NEM blockchain. Transaction could take some time. Come back here in 5 minutes to check your balance to ensure that the transaction was successfully sent\n'));
} catch (err) {
console.log(red(err));
}
} else {
console.log('Transaction canceled');
process.exit(1);
}
});
} catch (err) {
console.log(`\n${err}\n`);
}
});
示例3: function
rl.on("line", function(answer) {
current += answer;
ix++;
if(answer === "") {
ix = 1;
if(current) {
rl.write(CURSOR_UP_ONE + CURSOR_UP_ONE);
rl.clearLine();
console.log(" ");
try {
let code = current.trim();
if(current.indexOf("(query") !== 0
&& current.indexOf("(insert!") !== 0
&& current.indexOf("(remove!") !== 0
&& current.indexOf("(load!") !== 0
) {
code = `(query ${code})`;
}
ws.send(JSON.stringify({me, kind: "code", data: code}));
} catch(e) {
console.error(colors.red(e.message));
}
} else {
recurse();
}
current = "";
// rl.close();
} else {
recurse();
}
});
示例4: askUserInfo
]).then(function (answers) {
if (answers.password!=answers.repassword) {
console.error(colors.red("\nThe two passwords don't match!\n"));
askUserInfo(cb);
return;
}
cb(answers);
});
示例5: prettyPrintWarning
function prettyPrintWarning(warning) {
if (warning.fatal) {
fatalFailureOccurred = true;
}
const warningText = colors.red(warning.filename) + ":" +
warning.location.line + ":" + warning.location.column +
"\n " + colors.gray(warning.message);
logger.warn(warningText);
}
示例6: Password
}, (_, result) => {
const pass = new Password(result.password);
try {
resolve(wallet.open(pass));
} catch (err) {
console.log(red(`${err}`));
console.log(white('Please try again'));
reject();
}
});
示例7: Date
configurationsAPI.saveConfigruation('installed', {installation_time: new Date()}, (err) => {
if (err) {
console.error(colors.red("Ops! Something goes wrong! Please, try again!"));
console.dir(err);
return;
}
var table = new Table({
head: [colors.green('\n Installation completed! \n')],
chars: tableBorders
});
console.log(table.toString());
});
示例8: commitLog
export function commitLog(options: any) {
if (!!options.quiet) log.silence();
var repo = cwdRepo();
log.header('Commit Log');
var commit = repo.head.commit;
var graph = !!options.graph;
if (options.format === true) {
log.error('unknown log format');
return;
}
var format: string = options.format
|| (graph ? 'onelineWide' : 'short');
format = Format.decodeFormat(format);
if (!commit) {
log.warn('No commits found.');
return;
}
if (!!repo.merging) {
log.warn('In merging mode, latest commits not shown.');
}
while (!!commit) {
var nextCommit = commit.parent;
var isLastCommit = nextCommit == null;
var message = Format.formatCommitMessage(commit, format);
if (graph) {
var lines = message.split('\n');
if (lines.length == 1) {
log.log(colors.yellow('*'), message);
} else {
log.log(colors.yellow('*'), lines[0]);
for (var i = 1; i < lines.length; i++) {
if (isLastCommit) {
log.log(' ', lines[i]);
} else {
log.log(colors.red('|'), '', lines[i]);
}
}
}
} else {
log.log(message);
if (!isLastCommit) log.log();
}
commit = nextCommit;
}
}
示例9: async
}, async (_, result) => {
if (result.confirmation.toLowerCase() === 'y' || result.confirmation.toLowerCase() === 'yes') {
try {
const result = await sendMosaic(address, amt, selectedAccount);
console.log(result);
console.log('\n\n');
console.log(white('Transaction successfully announced to the NEM blockchain. Transaction could take some time. Come back here in 5 minutes to check your balance to ensure that the transaction was successfully sent\n'));
} catch (err) {
console.log(red(err));
}
} else {
console.log('Transaction canceled');
process.exit(1);
}
});
示例10: downloadWallet
const createPwd = () => {
console.log(white(
`\nPlease enter a unique password ${yellow('(8 character minimum)')}.\n
This password will be used to encrypt your private key and make working with your wallet easier.\n\n`
));
console.log(red(
`Store this password somewhere safe. If you lose or forget it you will never be able to transfer funds\n`
));
prompt.message = white(`${MOSAIC_NAME} wallet`);
prompt.start();
prompt.get({
properties: {
password: {
description: white('Password'),
hidden: true
},
confirmPass: {
description: white('Re-enter password'),
hidden: true
}
}
}, async (_, result) => {
if (result.password !== result.confirmPass) {
console.log(magenta('\nPasswords do not match.\n\n'));
createPwd();
} else {
/**
* Create new SimpleWallet
* Open it to access the new Account
* Print account info
*/
const wallet = createSimpleWallet(result.password);
const pass = new Password(result.password);
const account = wallet.open(pass);
const address = account.address.pretty();
console.log(green(`${MOSAIC_NAME} wallet successfully created.`));
console.log(white(`You can now start sending and receiving ${MOSAIC_NAME}!`));
console.log(white(`\n${MOSAIC_NAME} Public Address:`));
console.log(yellow(`${address}`));
console.log(white(`\nPrivate Key:`));
console.log(yellow(`${account.privateKey}`));
await downloadWallet(wallet);
}
})
};