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

carbone

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carbone - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

### v2.1.0
- Release September 1st, 2020
- Performance: huge gain from x11 to x30 for the compression of reports.
Now, some huge reports takes 0.1s to render instead of 4s.
It reduces also the blocking of Node's event loop.
- New rendering option `hardRefresh`: The content of the report is refreshed at the end of the Carbone process. For example, it can be used to refresh the table of content or update calculations. The option `convertTo` has to be defined.
### v2.0.2

@@ -2,0 +9,0 @@ - Release August 10th, 2020

2

formatters/date.js

@@ -75,4 +75,4 @@ var moment = require('moment');

module.exports = {
formatD : formatD,
formatD : formatD,
convDate : convDate
};

@@ -1,2 +0,1 @@

/* eslint-disable eqeqeq */
const locale = require('./_locale.js');

@@ -93,3 +92,6 @@ const currency = require('./_currency.js');

/**
* Format number according to the locale
* Format number according to the locale.
* Applying a number of decimals depends on the report type:
* - For ODS/XLSX, the number of decimals has to be formatted based on the text editor.
* - For the other type of files, the number of decimals depends on the `precision` parameter passed to the formatter.
*

@@ -101,3 +103,3 @@ * @exampleContext {"lang":"en-us"}

* @param {Number} d Number to format
* @param {Number} precision [optional] Number of decimal
* @param {Number} precision [optional] Number of decimals
* @return {String} return converted values

@@ -168,3 +170,5 @@ */

_currencyInfo.minSymbol,
// eslint-disable-next-line eqeqeq
(d != 1 ? _currencyInfo.major + 's' : _currencyInfo.major),
// eslint-disable-next-line eqeqeq
(d != 1 ? _currencyInfo.minor + 's' : _currencyInfo.minor),

@@ -171,0 +175,0 @@ _currencyInfo.name

var path = require('path');
var fs = require('fs');
var params = require('./params');
var zipWriter = require('moxie-zip').ZipWriter;
var yauzl = require('yauzl');
var unzipEmbeddedFileTypes = ['.xlsx', '.ods'];
var yazl = require('yazl');
var debug = require('debug')('carbone');

@@ -90,10 +91,24 @@ var file = {

zip : function (files, callback) {
var zip = new zipWriter();
var _buffer = [];
var _zip = new yazl.ZipFile();
_zip.outputStream.on('data', function (data) {
_buffer.push(data);
});
_zip.outputStream.on('error', function (err) {
debug('Error when building zip file ' + err);
});
_zip.outputStream.on('end', function () {
var _finalBuffer = Buffer.concat(_buffer);
callback(null, _finalBuffer);
});
for (var i = 0; i < files.length; i++) {
var _file = files[i];
zip.addData(_file.name, _file.data);
if (_file.name.endsWith('/') === true) {
_zip.addEmptyDirectory(_file.name);
}
else {
_zip.addBuffer(Buffer.from(_file.data), _file.name);
}
}
zip.toBuffer(function (buf) {
callback(null, buf);
});
_zip.end();
},

@@ -100,0 +115,0 @@

@@ -165,2 +165,3 @@ var fs = require('fs');

* 'currencyRates' : rates, based on EUR { EUR : 1, USD : 1.14 }
* 'hardRefresh' : (default: false) if true, LibreOffice is used to render and refresh the content of the report at the end of Carbone process
* }

@@ -184,3 +185,3 @@ * @param {Function} callbackRaw(err, res, reportName) : Function called after generation with the result

}
if (options.extension === options.convertTo) {
if (options.extension === options.convertTo && options.hardRefresh === false) {
options.convertTo = null; // avoid calling LibreOffice if the output file type is the same as the input file type

@@ -297,3 +298,4 @@ }

formatters : carbone.formatters,
existingVariables : variables
existingVariables : variables,
hardRefresh : options.hardRefresh || false
};

@@ -300,0 +302,0 @@ var _currency = _options.currency;

{
"name": "carbone",
"description": "Fast, Simple and Powerful report generator. Injects JSON and produces PDF, DOCX, XLSX, ODT, PPTX, ODS, ...!",
"version": "2.0.2",
"version": "2.1.0",
"bin": "bin/carbone",

@@ -22,4 +22,4 @@ "main": "./lib",

"test": "node ./node_modules/mocha/bin/mocha test --timeout 100000 --exit",
"lint": "eslint ./*/**.js",
"lint:fix": "eslint ./*/**.js --fix",
"lint": "eslint ./lib/**.js ./test/**.js ./formatters/**.js",
"lint:fix": "eslint ./lib/**.js ./test/**.js ./formatters/**.js --fix",
"postpublish": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push origin $PACKAGE_VERSION && git push github-origin $PACKAGE_VERSION"

@@ -30,9 +30,9 @@ },

"moment": "=2.27.0",
"moxie-zip": "=0.0.3",
"timsort": "=0.3.0",
"which": "=2.0.2",
"yauzl": "=2.10.0"
"yauzl": "=2.10.0",
"yazl": "=2.5.1"
},
"devDependencies": {
"eslint": "=7.3.1",
"eslint": "=7.7.0",
"mocha": "=3.5.3",

@@ -39,0 +39,0 @@ "zipfile": "=0.5.11"

@@ -33,6 +33,4 @@ <p align="center">

<p><b>Fast, Simple and Powerful report generator</b> in any format PDF, DOCX, XLSX, ODT, PPTX, ODS, XML, CSV...
<p><b>Fast, Simple and Powerful report generator</b> in any format PDF, DOCX, XLSX, ODT, PPTX, ODS, XML, CSV using your JSON data as input !</p>
... using your JSON data as input !</p>
> ⚡️ Breaking news :

@@ -42,6 +40,6 @@ >

>
> - `npm i carbone@2.0.0`
> - `npm i carbone@2.0.2`
> - Changelog : https://github.com/Ideolys/carbone/blob/master/CHANGELOG.md
> - The website and Carbone Render/Studio will be updated this week
README language: 🇨🇳 [简体中文](./doc/README.zh-cn.md), 🇺🇸 [English](README.md)

@@ -48,0 +46,0 @@ ## Table of content

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