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 1.2.0 to 1.2.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### v1.2.1
- Release June 11, 2019
- Fix `arrayMap()` if used with an array of strings or integer
### v1.2.0

@@ -2,0 +6,0 @@ - Release March 13, 2019

@@ -30,3 +30,4 @@

/**
* Flatten an array of objects?
* Flatten an array of objects
*
* It ignores nested objects and arrays

@@ -73,2 +74,5 @@ *

}
else if (_obj instanceof Object === false) {
_flatObj.push(_obj)
}
// else, loop on all attributes and print each one if it is not an object

@@ -75,0 +79,0 @@ else {

64

formatters/date.js

@@ -5,32 +5,6 @@ var moment = require('moment');

/**
* Format dates (DEPRECATED, use formatD instead)
* Format dates
*
* @exampleContext {"lang":"en"}
* @example ["20160131", "YYYYMMDD", "L"]
* @example ["20160131", "YYYYMMDD", "LL"]
* @example ["20160131", "YYYYMMDD", "LLLL"]
* @example ["20160131", "YYYYMMDD", "dddd"]
* @example [1410715640, "X", "LLLL"]
*
* @exampleContext {"lang":"fr"}
* @example ["20160131", "YYYYMMDD", "LLLL"]
* @example ["20160131", "YYYYMMDD", "dddd"]
* Since 1.2.0, by default, it considers the input format is "ISO 8601"
*
* @param {String|Number} d date to format
* @param {String} patternIn input format
* @param {String} patternOut output format
* @return {String} return formatted date
*/
function convDate (d, patternIn, patternOut) {
if (d !== null && typeof d !== 'undefined') {
moment.locale(this.lang);
return moment(d + '', patternIn).format(patternOut);
}
return d;
}
/**
* Format dates
* New since 1.2.0
*
* @exampleContext {"lang":"en"}

@@ -41,3 +15,2 @@ * @example ["20160131", "L"]

* @example ["20160131", "dddd"]
* @example [1410715640, "LLLL"]
*

@@ -70,2 +43,35 @@ * @exampleContext {"lang":"fr"}

/**
* Format dates
*
* @deprecated
*
* @exampleContext {"lang":"en"}
* @example ["20160131", "YYYYMMDD", "L"]
* @example ["20160131", "YYYYMMDD", "LL"]
* @example ["20160131", "YYYYMMDD", "LLLL"]
* @example ["20160131", "YYYYMMDD", "dddd"]
* @example [1410715640, "X", "LLLL"]
*
* @exampleContext {"lang":"fr"}
* @example ["20160131", "YYYYMMDD", "LLLL"]
* @example ["20160131", "YYYYMMDD", "dddd"]
*
* @param {String|Number} d date to format
* @param {String} patternIn input format
* @param {String} patternOut output format
* @return {String} return formatted date
*/
function convDate (d, patternIn, patternOut) {
if (d !== null && typeof d !== 'undefined') {
moment.locale(this.lang);
return moment(d + '', patternIn).format(patternOut);
}
return d;
}
module.exports = {

@@ -72,0 +78,0 @@ formatD : formatD,

@@ -7,3 +7,3 @@ const locale = require('./_locale.js');

*
* Fixed exchange rates are included by default in Carbone but you can provide a new echange rate
* Exchange rates are included by default in Carbone but you can provide a new echange rate
* for one report in `options.currencyRates` of `Carbone.render` or globally with `Carbone.set`

@@ -13,3 +13,3 @@ *

*
* @exampleContext {"currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 } } }
* @exampleContext {"currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 }} }
* @example [10 ]

@@ -43,8 +43,10 @@ * @example [1000 ]

*
* @param {Number} num number
* @param {Number} precision precision
* @example [10.05123 , 2 ]
* @example [1.05 , 1 ]
*
* @param {Number} num number
* @param {Number} precision number of decimal
* @return {Number}
*/
function round (num, precision) {
// Source: https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary
if (!('' + num).includes('e')) {

@@ -78,4 +80,5 @@ return +(Math.round(num + 'e+' + precision) + 'e-' + precision);

*
* @private
* @param {Number} value
* @param {Object} format
* @param {Number} value
* @param {Number} precision

@@ -120,13 +123,7 @@ * @return {String}

*
* If the formatter `convCurr() is used before, formatC prints the corresponding target currency used in `convCurr()`.
* If the formatter `convCurr()` is used before, formatC prints the corresponding target currency used in `convCurr()`.
*
* By default, it prints with the currency symbol only, but you can use other output formats:
*
* `precisionOrFormat` can be
* - Integer : change default precision of the currency
* - M : print Major currency name without the number
* - L : prints number with currency symbol (by default)
* - LL : prints number with Major currency name
*
* @exampleContext {"lang":"en-us", "currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 } } }
* @exampleContext {"lang":"en-us", "currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 }} }
* @example ["1000.456" ]

@@ -138,8 +135,16 @@ * @example ["1000.456", "M" ]

*
* @exampleContext {"lang":"fr-fr", "currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 } } }
* @exampleContext {"lang":"fr-fr", "currency": { "source":"EUR", "target":"USD", "rates": { "EUR":1, "USD":2 }} }
* @example ["1000.456" ]
*
* @exampleContext {"lang":"fr-fr", "currency": { "source":"EUR", "target":"EUR", "rates": { "EUR":1, "USD":2 }} }
* @example ["1000.456" ]
*
* @param {Number} d Number to format
* @param {Number} precisionOrFormat [optional] Number of decimal, or specific format
* @param {Number} precisionOrFormat [optional] Number of decimal, or specific format <br>
* - Integer : change default precision of the currency
* - M : print Major currency name without the number
* - L : prints number with currency symbol (by default)
* - LL : prints number with Major currency name
* @return {String} return converted values
*
*/

@@ -177,3 +182,3 @@ function formatC (d, precisionOrFormat) {

*
* @example [1000.4 , 2 ]
* @example [1000.4 , 2 ]
* @example ["1000.4", "2" ]

@@ -194,3 +199,3 @@ *

*
* @example [1000.4 , 2 ]
* @example [1000.4 , 2 ]
* @example ["1000.4", "2" ]

@@ -211,3 +216,3 @@ *

*
* @example [1000.4 , 2 ]
* @example [1000.4 , 2 ]
* @example ["1000.4", "2" ]

@@ -228,4 +233,4 @@ *

*
* @example [1000.4 , 2 ]
* @example ["1000.4", "2" ]
* @example [1000.4 , 2 ]
* @example ["1000.4" , "2" ]
*

@@ -254,3 +259,3 @@ * @param {Number} value Value to divide

* Converts a number to an INT
* DEPRECTAED
* @deprecated
*

@@ -265,3 +270,3 @@ * @return {Number}

* Converts a number with English specifications (decimal separator is '.')
* DEPRECTAED
* @deprecated
*

@@ -276,3 +281,3 @@ * @return {String}

* Converts a number into string, keeping only <nb> decimals
* DEPRECTAED
* @deprecated
*

@@ -288,3 +293,3 @@ * @param {Number} nb

* Converts a number with French specifications (decimal separator is ',')
* DEPRECTAED
* @deprecated
*

@@ -291,0 +296,0 @@ * @return {String}

@@ -180,8 +180,10 @@

*
* @example ["foorbar", 0, 2]
* @example ["foo"]
* @example ["foobar" , 0 , 3 ]
* @example ["foobar" , 1 ]
* @example ["foobar" , -2 ]
* @example ["foobar" , 2 , -1]
*
* @param {String} d
* @param {Integer} begin
* @param {Integer} end
* @param {Integer} begin Zero-based index at which to begin extraction.
* @param {Integer} end Zero-based index before which to end extraction
* @return {String} return the formatted string

@@ -188,0 +190,0 @@ */

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

@@ -6,0 +6,0 @@ "main": "./lib",

@@ -424,4 +424,4 @@ Carbone.io

- manage dynamic images
- manage dynamic colors
- manage dynamic images : Beta available only on SaaS version
- manage dynamic colors : Available only on SaaS version
- manage dynamic charts

@@ -428,0 +428,0 @@ - improve error output

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