Как обрезать строку до необходимой длины в iphone SDK?

Это список доступных цветов (фон, передний план) в консоли с доступными действиями (сброс, реверс, ...).

const colors = {
 Reset: "\x1b[0m",
 Bright: "\x1b[1m",
 Dim: "\x1b[2m",
 Underscore: "\x1b[4m",
 Blink: "\x1b[5m",
 Reverse: "\x1b[7m",
 Hidden: "\x1b[8m",
 fg: {
  Black: "\x1b[30m",
  Red: "\x1b[31m",
  Green: "\x1b[32m",
  Yellow: "\x1b[33m",
  Blue: "\x1b[34m",
  Magenta: "\x1b[35m",
  Cyan: "\x1b[36m",
  White: "\x1b[37m",
  Crimson: "\x1b[38m" //القرمزي
 },
 bg: {
  Black: "\x1b[40m",
  Red: "\x1b[41m",
  Green: "\x1b[42m",
  Yellow: "\x1b[43m",
  Blue: "\x1b[44m",
  Magenta: "\x1b[45m",
  Cyan: "\x1b[46m",
  White: "\x1b[47m",
  Crimson: "\x1b[48m"
 }
};

Используйте его как показано ниже:

 console.log(colors.bg.Blue, colors.fg.White , "I am white message with blue background", colors.Reset) ; 
 //don't forget "colors.Reset" to stop this color and return back to the default color

Вы также можете установить:

npm install console-info console-warn console-error --save-dev

IT даст вам выход ближе к консоли клиентской стороны:

13
задан monish 26 May 2010 в 11:43
поделиться