本文整理汇总了TypeScript中colors/safe.cyan函数的典型用法代码示例。如果您正苦于以下问题:TypeScript cyan函数的具体用法?TypeScript cyan怎么用?TypeScript cyan使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cyan函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: config
export function config(op: string, args: string[]) {
log.header('Configuration Manager');
switch (op) {
case "list": {
log.log(colors.cyan('Global'), 'options:');
var allConf = Common.iterateStringKeyObject<any>(conf.all);
allConf.forEach(v => {
if (!v.key.startsWith('repo_')) {
log.log(v.key, "=", v.value);
}
});
var repo = Common.cwdRepo();
if (!!repo) {
var lc = conf.get('repo_' + repo.name);
if (!!lc) {
log.log(colors.cyan('Local repository'), 'options:');
Common.iterateStringKeyObject<any>(lc).forEach(v => {
log.log(v.key, "=", v.value);
});
}
}
break;
}
case "set": {
if (args.length < 2) {
log.error('Not enough arguments for set operation.' +
'You must specify both key and value to set.');
return;
}
conf.set(args[0], args[1]);
log.log(args[0], '=', conf.get(args[0]));
break;
}
default: {
log.error('unknown operation');
break;
}
}
}
示例2: log
connection.on('misskey.log', (data: any) => {
const date = data.date;
const method = data.method;
const host = data.host;
const path = data.path;
const ua = data.ua;
const ip = data.ip;
const worker = data.worker;
/* tslint:disable max-line-length */
log(`${colors.gray(date)} ${method} ${colors.cyan(host)} ${colors.bold(path)} ${ua} ${colors.green(ip)} ${colors.gray('(' + worker + ')')}`);
/* tslint:enable max-line-length */
});
示例3: require
digitMatrices.forEach((matrix: IDigitMatrix) => {
let outputs = this.neuralNetwork.runWith(matrix.matrix);
let maximumValue = -Infinity;
let minimumValue = +Infinity;
let maximumNeuron = NaN;
for (let i = 0; i < outputs.length; i++) {
if (outputs[i] > maximumValue) {
maximumValue = outputs[i];
maximumNeuron = i;
}
if (outputs[i] < minimumValue) {
minimumValue = outputs[i];
}
}
let correct: boolean = maximumNeuron === matrix.digit;
if (correct) {
correctGuesses++;
}
if (print) {
let colors = require('colors/safe');
console.log();
let expected = 'Expected > ' + colors.green(matrix.digit);
let actual = 'Actual > ' + (correct ? colors.green(maximumNeuron) : colors.red(maximumNeuron));
Util.logTest('Output: ' + expected + ' ' + actual);
Util.logTest();
let result = 'CORRECT GUESS';
if (correct) {
result = colors.green(result);
} else {
result = colors.red('IN' + result);
}
Util.logTest(result);
Util.logTest();
Util.logTest('Neuron outputs:');
Util.logTest();
let valueRange = Math.abs(maximumValue - minimumValue);
for (let i = 0; i < outputs.length; i++) {
let neuronIndex = colors.cyan(i);
let prefix = ' ';
let suffix = ' ';
if (i === maximumNeuron) {
prefix = ' > ';
suffix = ' < ';
}
let neuronOutput = outputs[i];
let normalisedOutput = Math.floor((neuronOutput - minimumValue) / valueRange * 9);
let line = '';
for (let k = 0; k < 10; k++) {
if (k === normalisedOutput) {
line += colors.bgYellow(colors.black('â'));
} else {
line += colors.bgYellow(' ');
}
}
Util.logTest(prefix + neuronIndex + ' ' + line + ' ' + neuronIndex + suffix);
}
Util.logTest();
Util.logTest('Image of the digit:');
Util.logTest();
let printFunction = correct ? colors.green : colors.red;
DataParser.printImage(matrix.matrix, (line: string) => Util.logTest(printFunction(line)));
console.log();
}
});
示例4: format
formatter.on('Factor', (instance: FactorNode, format: (instance: IMathsNode) => string): string => {
return instance.bracketed ? (colors.cyan('(') + format(instance.subject) + colors.cyan(')')) : colors.white(format(instance.subject));
});
示例5: 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;
}
}
}
示例6: info
export function info(text: string) {
if (Config.debuglevel > 3) return
console.log(cyan('info') + ' ' + text)
}
示例7: config
export function config(op: string, args: string[]) {
log.header('Configuration Manager');
switch (op) {
case "list": {
log.log(colors.cyan('Global'), 'options:');
var allConf = Common.iterateStringKeyObject<any>(conf.all);
allConf.forEach(v => {
if (!v.key.startsWith('repo_')) {
log.log(v.key, "=", v.value);
}
});
let repo = Common.cwdRepo();
if (!!repo) {
var lc = conf.get('repo_' + repo.name);
if (!!lc) {
log.log(colors.cyan('Local repository'), 'options:');
Common.iterateStringKeyObject<any>(lc).forEach(v => {
log.log(v.key, "=", v.value);
});
}
}
break;
}
case "set": {
if (args.length < 2) {
log.error('Not enough arguments for set operation.' +
'You must specify both key and value to set.');
return;
}
var key = args[0];
let repo = Common.cwdRepo();
if (key.startsWith('this.')) {
if (!repo) {
log.error(`You use local repository referencing (${colors.italic('this.')})` +
` while outside of any repository directory. Aborting.`);
return;
}
key = key.replace('this.', 'repo_' + repo.name + '.');
}
conf.set(key, args[1]);
log.log(args[0], '=', conf.get(key));
break;
}
case "delete": {
let repo = cwdRepo();
if (args.length < 2) {
log.error('Not enough arguments for set operation.' +
'You must specify both key and value to set.');
return;
}
var key = args[0];
if (key.startsWith('this.')) {
key = key.replace('this.', 'repo_' + repo.name + '.');
}
conf.set(key, args[1]);
log.log(args[0], '=', conf.get(key));
break;
}
default: {
log.error('unknown operation');
break;
}
}
}