index.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. /*!
  2. * ansi-colors <https://github.com/doowb/ansi-colors>
  3. *
  4. * Copyright (c) 2015-2017, Brian Woodward.
  5. * Released under the MIT License.
  6. */
  7. 'use strict';
  8. /**
  9. * Module dependencies
  10. */
  11. var wrap = require('ansi-wrap');
  12. /**
  13. * Wrap a string with ansi codes to create a black background.
  14. *
  15. * ```js
  16. * console.log(colors.bgblack('some string'));
  17. * ```
  18. *
  19. * @param {string} message String to wrap with ansi codes.
  20. * @return {string} Wrapped string
  21. * @api public
  22. * @name bgblack
  23. */
  24. exports.bgblack = function bgblack(message) {
  25. return wrap(40, 49, message);
  26. };
  27. /**
  28. * Wrap a string with ansi codes to create a blue background.
  29. *
  30. * ```js
  31. * console.log(colors.bgblue('some string'));
  32. * ```
  33. *
  34. * @param {string} message String to wrap with ansi codes.
  35. * @return {string} Wrapped string
  36. * @api public
  37. * @name bgblue
  38. */
  39. exports.bgblue = function bgblue(message) {
  40. return wrap(44, 49, message);
  41. };
  42. /**
  43. * Wrap a string with ansi codes to create a cyan background.
  44. *
  45. * ```js
  46. * console.log(colors.bgcyan('some string'));
  47. * ```
  48. *
  49. * @param {string} message String to wrap with ansi codes.
  50. * @return {string} Wrapped string
  51. * @api public
  52. * @name bgcyan
  53. */
  54. exports.bgcyan = function bgcyan(message) {
  55. return wrap(46, 49, message);
  56. };
  57. /**
  58. * Wrap a string with ansi codes to create a green background.
  59. *
  60. * ```js
  61. * console.log(colors.bggreen('some string'));
  62. * ```
  63. *
  64. * @param {string} message String to wrap with ansi codes.
  65. * @return {string} Wrapped string
  66. * @api public
  67. * @name bggreen
  68. */
  69. exports.bggreen = function bggreen(message) {
  70. return wrap(42, 49, message);
  71. };
  72. /**
  73. * Wrap a string with ansi codes to create a magenta background.
  74. *
  75. * ```js
  76. * console.log(colors.bgmagenta('some string'));
  77. * ```
  78. *
  79. * @param {string} message String to wrap with ansi codes.
  80. * @return {string} Wrapped string
  81. * @api public
  82. * @name bgmagenta
  83. */
  84. exports.bgmagenta = function bgmagenta(message) {
  85. return wrap(45, 49, message);
  86. };
  87. /**
  88. * Wrap a string with ansi codes to create a red background.
  89. *
  90. * ```js
  91. * console.log(colors.bgred('some string'));
  92. * ```
  93. *
  94. * @param {string} message String to wrap with ansi codes.
  95. * @return {string} Wrapped string
  96. * @api public
  97. * @name bgred
  98. */
  99. exports.bgred = function bgred(message) {
  100. return wrap(41, 49, message);
  101. };
  102. /**
  103. * Wrap a string with ansi codes to create a white background.
  104. *
  105. * ```js
  106. * console.log(colors.bgwhite('some string'));
  107. * ```
  108. *
  109. * @param {string} message String to wrap with ansi codes.
  110. * @return {string} Wrapped string
  111. * @api public
  112. * @name bgwhite
  113. */
  114. exports.bgwhite = function bgwhite(message) {
  115. return wrap(47, 49, message);
  116. };
  117. /**
  118. * Wrap a string with ansi codes to create a yellow background.
  119. *
  120. * ```js
  121. * console.log(colors.bgyellow('some string'));
  122. * ```
  123. *
  124. * @param {string} message String to wrap with ansi codes.
  125. * @return {string} Wrapped string
  126. * @api public
  127. * @name bgyellow
  128. */
  129. exports.bgyellow = function bgyellow(message) {
  130. return wrap(43, 49, message);
  131. };
  132. /**
  133. * Wrap a string with ansi codes to create black text.
  134. *
  135. * ```js
  136. * console.log(colors.black('some string'));
  137. * ```
  138. *
  139. * @param {string} message String to wrap with ansi codes.
  140. * @return {string} Wrapped string
  141. * @api public
  142. * @name black
  143. */
  144. exports.black = function black(message) {
  145. return wrap(30, 39, message);
  146. };
  147. /**
  148. * Wrap a string with ansi codes to create blue text.
  149. *
  150. * ```js
  151. * console.log(colors.blue('some string'));
  152. * ```
  153. *
  154. * @param {string} message String to wrap with ansi codes.
  155. * @return {string} Wrapped string
  156. * @api public
  157. * @name blue
  158. */
  159. exports.blue = function blue(message) {
  160. return wrap(34, 39, message);
  161. };
  162. /**
  163. * Wrap a string with ansi codes to create bold text.
  164. *
  165. * ```js
  166. * console.log(colors.bold('some string'));
  167. * ```
  168. *
  169. * @param {string} message String to wrap with ansi codes.
  170. * @return {string} Wrapped string
  171. * @api public
  172. * @name bold
  173. */
  174. exports.bold = function bold(message) {
  175. return wrap(1, 22, message);
  176. };
  177. /**
  178. * Wrap a string with ansi codes to create cyan text.
  179. *
  180. * ```js
  181. * console.log(colors.cyan('some string'));
  182. * ```
  183. *
  184. * @param {string} message String to wrap with ansi codes.
  185. * @return {string} Wrapped string
  186. * @api public
  187. * @name cyan
  188. */
  189. exports.cyan = function cyan(message) {
  190. return wrap(36, 39, message);
  191. };
  192. /**
  193. * Wrap a string with ansi codes to create dim text.
  194. *
  195. * ```js
  196. * console.log(colors.dim('some string'));
  197. * ```
  198. *
  199. * @param {string} message String to wrap with ansi codes.
  200. * @return {string} Wrapped string
  201. * @api public
  202. * @name dim
  203. */
  204. exports.dim = function dim(message) {
  205. return wrap(2, 22, message);
  206. };
  207. /**
  208. * Wrap a string with ansi codes to create gray text.
  209. *
  210. * ```js
  211. * console.log(colors.gray('some string'));
  212. * ```
  213. *
  214. * @param {string} message String to wrap with ansi codes.
  215. * @return {string} Wrapped string
  216. * @api public
  217. * @name gray
  218. */
  219. exports.gray = function gray(message) {
  220. return wrap(90, 39, message);
  221. };
  222. /**
  223. * Wrap a string with ansi codes to create green text.
  224. *
  225. * ```js
  226. * console.log(colors.green('some string'));
  227. * ```
  228. *
  229. * @param {string} message String to wrap with ansi codes.
  230. * @return {string} Wrapped string
  231. * @api public
  232. * @name green
  233. */
  234. exports.green = function green(message) {
  235. return wrap(32, 39, message);
  236. };
  237. /**
  238. * Wrap a string with ansi codes to create grey text.
  239. *
  240. * ```js
  241. * console.log(colors.grey('some string'));
  242. * ```
  243. *
  244. * @param {string} message String to wrap with ansi codes.
  245. * @return {string} Wrapped string
  246. * @api public
  247. * @name grey
  248. */
  249. exports.grey = function grey(message) {
  250. return wrap(90, 39, message);
  251. };
  252. /**
  253. * Wrap a string with ansi codes to create hidden text.
  254. *
  255. * ```js
  256. * console.log(colors.hidden('some string'));
  257. * ```
  258. *
  259. * @param {string} message String to wrap with ansi codes.
  260. * @return {string} Wrapped string
  261. * @api public
  262. * @name hidden
  263. */
  264. exports.hidden = function hidden(message) {
  265. return wrap(8, 28, message);
  266. };
  267. /**
  268. * Wrap a string with ansi codes to create inverse text.
  269. *
  270. * ```js
  271. * console.log(colors.inverse('some string'));
  272. * ```
  273. *
  274. * @param {string} message String to wrap with ansi codes.
  275. * @return {string} Wrapped string
  276. * @api public
  277. * @name inverse
  278. */
  279. exports.inverse = function inverse(message) {
  280. return wrap(7, 27, message);
  281. };
  282. /**
  283. * Wrap a string with ansi codes to create italic text.
  284. *
  285. * ```js
  286. * console.log(colors.italic('some string'));
  287. * ```
  288. *
  289. * @param {string} message String to wrap with ansi codes.
  290. * @return {string} Wrapped string
  291. * @api public
  292. * @name italic
  293. */
  294. exports.italic = function italic(message) {
  295. return wrap(3, 23, message);
  296. };
  297. /**
  298. * Wrap a string with ansi codes to create magenta text.
  299. *
  300. * ```js
  301. * console.log(colors.magenta('some string'));
  302. * ```
  303. *
  304. * @param {string} message String to wrap with ansi codes.
  305. * @return {string} Wrapped string
  306. * @api public
  307. * @name magenta
  308. */
  309. exports.magenta = function magenta(message) {
  310. return wrap(35, 39, message);
  311. };
  312. /**
  313. * Wrap a string with ansi codes to create red text.
  314. *
  315. * ```js
  316. * console.log(colors.red('some string'));
  317. * ```
  318. *
  319. * @param {string} message String to wrap with ansi codes.
  320. * @return {string} Wrapped string
  321. * @api public
  322. * @name red
  323. */
  324. exports.red = function red(message) {
  325. return wrap(31, 39, message);
  326. };
  327. /**
  328. * Wrap a string with ansi codes to reset ansi colors currently on the string.
  329. *
  330. * ```js
  331. * console.log(colors.reset('some string'));
  332. * ```
  333. *
  334. * @param {string} message String to wrap with ansi codes.
  335. * @return {string} Wrapped string
  336. * @api public
  337. * @name reset
  338. */
  339. exports.reset = function reset(message) {
  340. return wrap(0, 0, message);
  341. };
  342. /**
  343. * Wrap a string with ansi codes to add a strikethrough to the text.
  344. *
  345. * ```js
  346. * console.log(colors.strikethrough('some string'));
  347. * ```
  348. *
  349. * @param {string} message String to wrap with ansi codes.
  350. * @return {string} Wrapped string
  351. * @api public
  352. * @name strikethrough
  353. */
  354. exports.strikethrough = function strikethrough(message) {
  355. return wrap(9, 29, message);
  356. };
  357. /**
  358. * Wrap a string with ansi codes to underline the text.
  359. *
  360. * ```js
  361. * console.log(colors.underline('some string'));
  362. * ```
  363. *
  364. * @param {string} message String to wrap with ansi codes.
  365. * @return {string} Wrapped string
  366. * @api public
  367. * @name underline
  368. */
  369. exports.underline = function underline(message) {
  370. return wrap(4, 24, message);
  371. };
  372. /**
  373. * Wrap a string with ansi codes to create white text.
  374. *
  375. * ```js
  376. * console.log(colors.white('some string'));
  377. * ```
  378. *
  379. * @param {string} message String to wrap with ansi codes.
  380. * @return {string} Wrapped string
  381. * @api public
  382. * @name white
  383. */
  384. exports.white = function white(message) {
  385. return wrap(37, 39, message);
  386. };
  387. /**
  388. * Wrap a string with ansi codes to create yellow text.
  389. *
  390. * ```js
  391. * console.log(colors.yellow('some string'));
  392. * ```
  393. *
  394. * @param {string} message String to wrap with ansi codes.
  395. * @return {string} Wrapped string
  396. * @api public
  397. * @name yellow
  398. */
  399. exports.yellow = function yellow(message) {
  400. return wrap(33, 39, message);
  401. };