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

tabacol

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tabacol - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

package.json
{
"name": "tabacol",
"version": "0.2.1",
"version": "0.2.2",
"description": "Output a table in string format from data in JSON format",

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

@@ -26,6 +26,9 @@ /**

nmd.columns.map((e, i) => {
let pad = e.spaceLeft ? e.spaceLeft : 0;
pad = e.spaceRight ? pad + e.spaceRight : pad;
if (e.type === 'fixedAbsolute') totalFixedAbsolute += e.size;
else if (e.type === 'fixedPercent') totalFixedPercent += (globalMaxWidth / 100) * e.size;
else if (e.type === 'fixedContent') totalFixedContent += longestContent[i];
else if (e.type === 'upToContent') totalUpToContent += longestContent[i];
else if (e.type === 'fixedContent') totalFixedContent += longestContent[i] + pad;
else if (e.type === 'upToContent') totalUpToContent += longestContent[i] + pad;
else if (e.type === 'left') totalLeft += longestContent[i];

@@ -52,7 +55,9 @@ return e;

let finalWidth;
let pad = e.spaceLeft ? e.spaceLeft : 0;
pad = e.spaceRight ? pad + e.spaceRight : pad;
if (e.type === 'fixedAbsolute') finalWidth = e.size;
else if (e.type === 'fixedContent') finalWidth = longestContent[i];
else if (e.type === 'fixedContent') finalWidth = longestContent[i] + pad;
else if (e.type === 'fixedPercent') finalWidth = Math.round((globalMaxWidth / 100) * e.size);
else if (e.type === 'upToContent') finalWidth = Math.round(upToContentCoef * longestContent[i]);
else if (e.type === 'upToContent') finalWidth = Math.round(upToContentCoef * longestContent[i]) + pad;
else if (e.type === 'left') finalWidth = Math.round(leftCoef * longestContent[i]);

@@ -59,0 +64,0 @@

@@ -12,2 +12,10 @@ const chai = require('chai');

const testData2 = [
['l1 - c1'],
['l1 - c2'],
['l1 - c3'],
['l1 - c4'],
['l1 - c5'],
];
const testFormatColFixedAbsolute1 = {

@@ -79,5 +87,7 @@ maxTotalWidth: 80,

columns: [
{ spaceLeft: 0, spaceRight: 2, type: 'fixedAbsolute', size: 15 },
{ spaceLeft: 1, spaceRight: 2, type: 'fixedPercent', size: 20 },
{ spaceLeft: 2, spaceRight: 2, type: 'left' },
{ spaceLeft: 1, spaceRight: 1, type: 'fixedAbsolute', size: 10 },
{ spaceLeft: 1, spaceRight: 1, type: 'fixedPercent', size: 20 },
{ spaceLeft: 1, spaceRight: 1, type: 'fixedContent' },
{ spaceLeft: 1, spaceRight: 1, type: 'upToContent' },
{ spaceLeft: 1, spaceRight: 1, type: 'left' },
],

@@ -154,8 +164,10 @@ };

it('should return the metadata containing the proper column widths', (done) => {
const res = compute.computeWidth(testData1, testFormatColMixed);
expect(res.columns[0].finalWidth).to.equal(15);
const res = compute.computeWidth(testData2, testFormatColMixed);
expect(res.columns[0].finalWidth).to.equal(10);
expect(res.columns[1].finalWidth).to.equal(16);
expect(res.columns[2].finalWidth).to.equal(49);
expect(res.columns[2].finalWidth).to.equal(9);
expect(res.columns[3].finalWidth).to.equal(9);
expect(res.columns[4].finalWidth).to.equal(36);
done();
});
});
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