本文整理汇总了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;
}
}
}
开发者ID:habukira,项目名称:Azure-azure-iot-device-management,代码行数:27,代码来源:dmuxLogStream.ts
示例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`);
}
});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:52,代码来源:wallet-cli.ts
示例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();
}
});
开发者ID:AtnNn,项目名称:Eve,代码行数:32,代码来源:repl.ts
示例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);
});
开发者ID:portalTS,项目名称:portalTS,代码行数:8,代码来源:index.ts
示例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);
}
开发者ID:PolymerLabs,项目名称:polylint,代码行数:9,代码来源:cli.ts
示例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();
}
});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:10,代码来源:wallet-cli.ts
示例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());
});
开发者ID:portalTS,项目名称:portalTS,代码行数:12,代码来源:index.ts
示例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;
}
}
开发者ID:STALKER2010,项目名称:jerk,代码行数:53,代码来源:cli.ts
示例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);
}
});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:16,代码来源:wallet-cli.ts
示例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);
}
})
};
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:45,代码来源:wallet-cli.ts
注:本文中的colors/safe.red函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论