New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

console-grid

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-grid - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

88

lib/index.js
const Style = require("./style.js");
const comparers = require("./comparers.js");
class ConsoleGrid {

@@ -388,7 +389,20 @@ constructor() {

//=====================================================================================================
getTruncatedCharByWidth(str, w) {
str = this.removeColor(str);
var res = "";
for (var i = 0, l = str.length; i < l; i++) {
var c = str.charAt(i);
var temp = res + c + "...";
var len = this.getCharLength(temp);
if (len > w) {
return res + "...";
}
res += c;
}
return res + "...";
}
getCharByWidth(str, w) {
var strNoColor = this.removeColor(str);
if (strNoColor.length <= w) {
return str;
if (w <= 3) {
return this.getChar(w, ".");
}

@@ -401,5 +415,3 @@

if (lenNoColor > w) {
item = this.removeColor(item);
item = item.substr(0, w - 3) + "...";
return item;
return this.getTruncatedCharByWidth(item, w);
}

@@ -439,7 +451,67 @@

//https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms_(Unicode_block)
//http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
/*eslint-disable complexity */
isNarrowCharacter(character) {
const cp = character.codePointAt(0);
var border = [
0x2500,
0x2502,
0x250c,
0x252c,
0x2510,
0x251c,
0x253c,
0x2524,
0x2514,
0x2534,
0x2518
];
if (border.indexOf(cp) !== -1) {
return true;
}
return (
(cp >= 0x20 && cp <= 0x7E) ||
cp === 0xA2 ||
cp === 0xA3 ||
cp === 0xA5 ||
cp === 0xA6 ||
cp === 0xAC ||
cp === 0xAF ||
cp === 0x20A9 ||
(cp >= 0x27E6 && cp <= 0x27ED) ||
cp === 0x2985 ||
cp === 0x2986 ||
(cp >= 0xFF61 && cp <= 0xFFBE) ||
(cp >= 0xFFC2 && cp <= 0xFFC7) ||
(cp >= 0xFFCA && cp <= 0xFFCF) ||
(cp >= 0xFFD2 && cp <= 0xFFD7) ||
(cp >= 0xFFDA && cp <= 0xFFDC) ||
(cp >= 0xFFE8 && cp <= 0xFFEE)
);
}
/*eslint-enable */
getByteLen(str) {
var len = 0;
var max = str.length;
var i = 0;
while (i < max) {
var c = str.charAt(i);
if (this.isNarrowCharacter(c)) {
len += 1;
} else {
len += 2;
}
i++;
}
return len;
}
getCharLength(char) {
//console.log(char, char.length);
char = this.removeColor(char);
//console.log(char, char.length);
return char.length;
var len = this.getByteLen(char);
//console.log(char, len);
return len;
}

@@ -446,0 +518,0 @@

2

package.json
{
"name": "console-grid",
"version": "1.0.13",
"version": "1.0.14",
"description": "console log a grid",

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

@@ -169,2 +169,8 @@ # console-grid

```
![screenshot](test/console-grid-screenshot.png)
![screenshot](test/test.jpg)
# CHANGELOG
### v1.0.14
* support fullWidth Unicode
---
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