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

flexmonster-compressor

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flexmonster-compressor - npm Package Compare versions

Comparing version 2.7.16 to 2.7.17

2

package.json
{
"name": "flexmonster-compressor",
"version": "2.7.16",
"version": "2.7.17",
"description": "Flexmonster Compressor for Node.js – a special server-side compression tool that helps you to increase data loading speed from server to Flexmonster Pivot Table component.",

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

@@ -64,3 +64,3 @@ const version = require('../version');

for (let colIdx = 0; colIdx < this._header.length; colIdx++) {
result.push(values[colIdx] ? values[colIdx].toString() : "");
result.push(this.convertValue(values[colIdx], colIdx));
}

@@ -70,2 +70,53 @@ return result.join(",") + "\n";

convertValue(value, colIdx) {
let type = this._header[colIdx].type;
if (type == ColumnType.FACT) {
return value ? this.toNumber(value) : "";
} else if (type == ColumnType.STRING || type == ColumnType.WEEKDAY || type == ColumnType.MONTH || type == ColumnType.LEVELS) {
let v = value ? value.toString() : "";
return `"${v}"`;
} else if (type == ColumnType.DATE ||
type == ColumnType.DATE_STRING ||
type == ColumnType.DATE_WITH_MONTHS ||
type == ColumnType.DATE_WITH_QUARTERS) {
return new Date(moment.utc(value).valueOf() - this._timeZoneOffset * 1000).toISOString();
} else if (type == ColumnType.DATETIME) {
if (value instanceof Date) {
return value.toISOString();
} else if (typeof value == "number") {
return new Date(value).toISOString();
}
} else if (type == ColumnType.TIME) {
if (value instanceof Date) {
return value.getTime();
}
if (typeof value == "string") {
return this.timeStrToSeconds(value)
}
}
return value ? value.toString() : "";
}
timeStrToSeconds(timeStr) {
var timeParts = timeStr.split(":");
if (timeParts.length == 1) {
return parseInt(timeParts[0]);
}
var hh = parseInt(timeParts[0]);
var mm = parseInt(timeParts[1]);
var ss = parseInt(timeParts[2]);
return isNaN(ss) ? hh * 60 + mm :
hh * 3600 + mm * 60 + ss;
}
toNumber(value) {
if (value == null) return NaN;
if (typeof value === 'number') return value;
if (typeof value !== 'string') value = value.toString();
var _pattern = /[^[,|\.|\-|\d|e]]*/gi;
value = value.replace(",", ".");
value = value.replace(_pattern, "");
return parseFloat(value);
}
encodeChars(input) {

@@ -72,0 +123,0 @@ return input.replace(/,/g, "%d%").replace(/"/g, "%q%").replace(/\n/g, "%n%");

module.exports = {
VERSION: "2.7.16",
VERSION: "2.7.17",
VERSION_COMPATIBLE: "2.7.13"
}

@@ -17,3 +17,3 @@ const assert = require('assert');

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field\nValue 2\n`;
let actual = `+Field\n"Value 2"\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -36,3 +36,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field\nValue 2\nValue 2\n`;
let actual = `+Field\n"Value 2"\n"Value 2"\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -55,3 +55,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field\n123\nValue 2\n`;
let actual = `+Field\n"123"\n"Value 2"\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -130,3 +130,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `m+Field\nApril\nJanuary\nJanuary\n`;
let actual = `m+Field\n"April"\n"January"\n"January"\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -154,3 +154,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `w+Field\nWednesday\nMonday\nMonday\n`;
let actual = `w+Field\n"Wednesday"\n"Monday"\n"Monday"\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -167,3 +167,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `d+Field\n2016-01-20\n`;
let actual = `d+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -177,3 +177,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `d+Field\nWed Jan 20 2016 02:00:00 GMT+0200 (Eastern European Standard Time)\n`;
let actual = `d+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -193,3 +193,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `d+Field\n1453248000000\n`;
let actual = `d+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -209,3 +209,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `d+Field\n2016-01-20\n`;
let actual = `d+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -225,3 +225,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `d+Field\n1915-01-20\n`;
let actual = `d+Field\n1915-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -243,3 +243,3 @@ });

}));
let actual = `d+Field\n2016-01-20\n`;
let actual = `d+Field\n2016-01-19T22:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -261,3 +261,3 @@ });

}));
let actual = `d+Field\n2016-01-20\n`;
let actual = `d+Field\n2016-01-20T02:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -279,3 +279,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `ds+Field\n2016-01-20\n`;
let actual = `ds+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -297,3 +297,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `D+Field\n2016-01-20\n`;
let actual = `D+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -315,3 +315,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `D4+Field\n2016-01-20\n`;
let actual = `D4+Field\n2016-01-20T00:00:00.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -363,3 +363,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `t+Field\nThu Jan 01 1970 03:00:00 GMT+0300 (Eastern European Standard Time)\n`;
let actual = `t+Field\n100\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -381,3 +381,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `dt+Field\n1453413599000\n`;
let actual = `dt+Field\n2016-01-21T21:59:59.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -397,3 +397,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `dt+Field\nThu Jan 21 2016 23:59:59 GMT+0200 (Eastern European Standard Time)\n`;
let actual = `dt+Field\n2016-01-21T21:59:59.000Z\n`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -425,3 +425,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Country,+Country:State,+Country:State:City\nUSA,CA,Los Angeles`;
let actual = `+Country,+Country:State,+Country:State:City\n"USA","CA","Los Angeles"`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -447,3 +447,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field,-Price\nValue1,99\nValue1,99`;
let actual = `+Field,-Price\n"Value1",99\n"Value1",99`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -457,3 +457,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field,d+Date\nValue1,2018-01-01`;
let actual = `+Field,d+Date\n"Value1",2018-01-01T00:00:00.000Z`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -473,3 +473,3 @@ });

let compressed = await toString(compressor.compressJson(json));
let actual = `+Field,ds+Date\nValue1,2018-01-01`;
let actual = `+Field,ds+Date\n"Value1",2018-01-01T00:00:00.000Z`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -529,3 +529,3 @@ });

compressed = compressed.trim();
let actual = "Column\nval";
let actual = `Column\n"val"`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -558,3 +558,3 @@ });

compressed = compressed.trim();
let actual = "Column\nval";
let actual = `Column\n"val"`;
assert.equal(removeHeaders(compressed), removeHeaders(actual));

@@ -561,0 +561,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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