Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magicpen

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magicpen - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

39

lib/AnsiSerializer.js

@@ -17,3 +17,3 @@ var shim = require('./shim');

var colorPaletteByNumberOfColors = {
var colorPalettes = {
16: {

@@ -33,3 +33,3 @@ '#000000': 'black',

var diffPaletteByNumberOfColors = {};
var diffPalettes = {};

@@ -61,8 +61,11 @@ function convertColorToObject(color) {

diffPaletteByNumberOfColors[16] = shim.map(getKeys(colorPaletteByNumberOfColors[16]), convertColorToObject);
diffPaletteByNumberOfColors[256] = [].concat(diffPaletteByNumberOfColors[16]);
diffPalettes[16] = shim.map(getKeys(colorPalettes[16]), convertColorToObject);
diffPalettes['bg16'] = shim.map(shim.filter(getKeys(colorPalettes[16]), function (color) {
return color !== "#808080";
}), convertColorToObject);
diffPalettes[256] = [].concat(diffPalettes[16]);
var nextAnsiColorNumber = 16;
function registerNext256PaletteEntry(obj) {
diffPaletteByNumberOfColors[256].push(obj);
colorPaletteByNumberOfColors[256][toHexColor(obj)] = nextAnsiColorNumber;
diffPalettes[256].push(obj);
colorPalettes[256][toHexColor(obj)] = nextAnsiColorNumber;
nextAnsiColorNumber += 1;

@@ -75,5 +78,5 @@ }

registerNext256PaletteEntry({
R: Math.round(r * 256/6),
G: Math.round(g * 256/6),
B: Math.round(b * 256/6)
R: Math.round(r * 256 / 6),
G: Math.round(g * 256 / 6),
B: Math.round(b * 256 / 6)
});

@@ -91,8 +94,2 @@ }

function findClosestColorInDiffPalette(color, numberOfColors) {
var colorObject = colorDiff.closest(convertColorToObject(color), diffPaletteByNumberOfColors[numberOfColors]);
return colorPaletteByNumberOfColors[numberOfColors][toHexColor(colorObject)];
}
var rgbRegexp = /^(?:bg)?#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;

@@ -111,10 +108,9 @@ AnsiSerializer.prototype.text = function (content) {

var color16Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPaletteByNumberOfColors[16]));
var closestColor16 = colorPaletteByNumberOfColors[16][color16Hex];
var color16Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName),
diffPalettes[isBackgroundColor ? 'bg16' : 16]));
var closestColor16 = colorPalettes[16][color16Hex];
var color256Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPaletteByNumberOfColors[256]));
var closest256ColorIndex = colorPaletteByNumberOfColors[256][color256Hex];
var color256Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPalettes[256]));
var closest256ColorIndex = colorPalettes[256][color256Hex];
var closestColor16 = findClosestColorInDiffPalette(colorName, 16);
var closest256ColorIndex = findClosestColorInDiffPalette(isBackgroundColor ? styleName.substring(2) : styleName, 256);
if (isBackgroundColor) {

@@ -125,2 +121,3 @@ styleName = 'bg' + firstUp(closestColor16);

}
var open = ansiStyles[styleName].open;

@@ -127,0 +124,0 @@ var close = ansiStyles[styleName].close;

@@ -41,3 +41,3 @@ /*!

var colorPaletteByNumberOfColors = {
var colorPalettes = {
16: {

@@ -57,3 +57,3 @@ '#000000': 'black',

var diffPaletteByNumberOfColors = {};
var diffPalettes = {};

@@ -85,8 +85,11 @@ function convertColorToObject(color) {

diffPaletteByNumberOfColors[16] = shim.map(getKeys(colorPaletteByNumberOfColors[16]), convertColorToObject);
diffPaletteByNumberOfColors[256] = [].concat(diffPaletteByNumberOfColors[16]);
diffPalettes[16] = shim.map(getKeys(colorPalettes[16]), convertColorToObject);
diffPalettes['bg16'] = shim.map(shim.filter(getKeys(colorPalettes[16]), function (color) {
return color !== "#808080";
}), convertColorToObject);
diffPalettes[256] = [].concat(diffPalettes[16]);
var nextAnsiColorNumber = 16;
function registerNext256PaletteEntry(obj) {
diffPaletteByNumberOfColors[256].push(obj);
colorPaletteByNumberOfColors[256][toHexColor(obj)] = nextAnsiColorNumber;
diffPalettes[256].push(obj);
colorPalettes[256][toHexColor(obj)] = nextAnsiColorNumber;
nextAnsiColorNumber += 1;

@@ -99,5 +102,5 @@ }

registerNext256PaletteEntry({
R: Math.round(r * 256/6),
G: Math.round(g * 256/6),
B: Math.round(b * 256/6)
R: Math.round(r * 256 / 6),
G: Math.round(g * 256 / 6),
B: Math.round(b * 256 / 6)
});

@@ -115,8 +118,2 @@ }

function findClosestColorInDiffPalette(color, numberOfColors) {
var colorObject = colorDiff.closest(convertColorToObject(color), diffPaletteByNumberOfColors[numberOfColors]);
return colorPaletteByNumberOfColors[numberOfColors][toHexColor(colorObject)];
}
var rgbRegexp = /^(?:bg)?#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;

@@ -135,10 +132,9 @@ AnsiSerializer.prototype.text = function (content) {

var color16Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPaletteByNumberOfColors[16]));
var closestColor16 = colorPaletteByNumberOfColors[16][color16Hex];
var color16Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName),
diffPalettes[isBackgroundColor ? 'bg16' : 16]));
var closestColor16 = colorPalettes[16][color16Hex];
var color256Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPaletteByNumberOfColors[256]));
var closest256ColorIndex = colorPaletteByNumberOfColors[256][color256Hex];
var color256Hex = toHexColor(colorDiff.closest(convertColorToObject(colorName), diffPalettes[256]));
var closest256ColorIndex = colorPalettes[256][color256Hex];
var closestColor16 = findClosestColorInDiffPalette(colorName, 16);
var closest256ColorIndex = findClosestColorInDiffPalette(isBackgroundColor ? styleName.substring(2) : styleName, 256);
if (isBackgroundColor) {

@@ -149,2 +145,3 @@ styleName = 'bg' + firstUp(closestColor16);

}
var open = ansiStyles[styleName].open;

@@ -1058,3 +1055,3 @@ var close = ansiStyles[styleName].close;

else if((h2p-h1p) < -180) return (h2p-h1p)+360;
else throw(new Error());
else throw(error);
}

@@ -1075,3 +1072,3 @@ var dhp = dhp_f(C1,C2, h1p, h2p); //(10)

else if((abs(h1p-h2p) > 180) && ((h1p+h2p) >= 360)) return (h1p+h2p-360)/2.0;
else throw(new Error());
else throw(error);
}

@@ -1196,3 +1193,3 @@ var a_hp = a_hp_f(C1,C2,h1p,h2p); //(14)

{
var color2 = b[idx2];
var color2 = b[idx2]
var current_color_diff = diff(color1,color2);

@@ -1199,0 +1196,0 @@ if((best_color == undefined) || (current_color_diff < best_color_diff))

{
"name": "magicpen",
"version": "0.5.0",
"version": "0.5.1",
"description": "Styled output in both consoles and browsers",

@@ -5,0 +5,0 @@ "main": "./lib/MagicPen.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc