@palett/util-ansi
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -5,4 +5,9 @@ 'use strict'; | ||
var convert = require('@palett/convert'); | ||
const CLR_ALL = '0'; | ||
const ESC = '\u001b'; | ||
const L = ESC + '['; | ||
const R = 'm'; | ||
const SC = ';'; | ||
@@ -65,15 +70,27 @@ const FORE = '38;2'; | ||
* | ||
* @param {string[]} config | ||
* @param {string[]} codes | ||
* @returns {string} | ||
*/ | ||
const br = config => `${ESC}[${config.join(';')}m`; | ||
const br = codes => L + codes.join(SC) + R; | ||
/** | ||
* | ||
* @param {string} config | ||
* @param {string} code | ||
* @returns {string} | ||
*/ | ||
const brt = config => `${ESC}[${config}m`; | ||
const brt = code => L + code + R; | ||
/** | ||
* | ||
* @param {number[]} rgb - array of three integers, each from 0 to 255 | ||
* @returns {string} | ||
*/ | ||
const rgbToAnsi = rgb => FORE + SC + rgb[0] + SC + rgb[1] + SC + rgb[2]; | ||
const hexToAnsi = hex => { | ||
const int = convert.hexToInt(hex); | ||
return FORE + SC + (int >> 16 & 0xFF) + SC + (int >> 8 & 0xFF) + SC + (int & 0xFF); | ||
}; | ||
exports.BACK = BACK; | ||
@@ -87,3 +104,8 @@ exports.CLR_ALL = CLR_ALL; | ||
exports.FORE = FORE; | ||
exports.L = L; | ||
exports.R = R; | ||
exports.SC = SC; | ||
exports.br = br; | ||
exports.brt = brt; | ||
exports.hexToAnsi = hexToAnsi; | ||
exports.rgbToAnsi = rgbToAnsi; |
@@ -0,3 +1,8 @@ | ||
import { hexToInt } from '@palett/convert'; | ||
const CLR_ALL = '0'; | ||
const ESC = '\u001b'; | ||
const L = ESC + '['; | ||
const R = 'm'; | ||
const SC = ';'; | ||
@@ -60,15 +65,27 @@ const FORE = '38;2'; | ||
* | ||
* @param {string[]} config | ||
* @param {string[]} codes | ||
* @returns {string} | ||
*/ | ||
const br = config => `${ESC}[${config.join(';')}m`; | ||
const br = codes => L + codes.join(SC) + R; | ||
/** | ||
* | ||
* @param {string} config | ||
* @param {string} code | ||
* @returns {string} | ||
*/ | ||
const brt = config => `${ESC}[${config}m`; | ||
const brt = code => L + code + R; | ||
export { BACK, CLR_ALL, CLR_BACK, CLR_FORE, ConsoleColors, ESC, Effects, FORE, br, brt }; | ||
/** | ||
* | ||
* @param {number[]} rgb - array of three integers, each from 0 to 255 | ||
* @returns {string} | ||
*/ | ||
const rgbToAnsi = rgb => FORE + SC + rgb[0] + SC + rgb[1] + SC + rgb[2]; | ||
const hexToAnsi = hex => { | ||
const int = hexToInt(hex); | ||
return FORE + SC + (int >> 16 & 0xFF) + SC + (int >> 8 & 0xFF) + SC + (int & 0xFF); | ||
}; | ||
export { BACK, CLR_ALL, CLR_BACK, CLR_FORE, ConsoleColors, ESC, Effects, FORE, L, R, SC, br, brt, hexToAnsi, rgbToAnsi }; |
{ | ||
"name": "@palett/util-ansi", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "A color converter", | ||
@@ -19,3 +19,3 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@palett/convert": "^0.0.15" | ||
"@palett/convert": "^0.0.16" | ||
}, | ||
@@ -40,3 +40,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/palett/util-ansi#readme", | ||
"gitHead": "0c47b12f229babf25f5841925245a1d2d63fda01" | ||
"gitHead": "64ccfe78f8e7d28e40901daf6c9dabbdd7891ced" | ||
} |
6635
176
+ Added@palett/convert@0.0.16(transitive)
- Removed@palett/convert@0.0.15(transitive)
Updated@palett/convert@^0.0.16