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

kitten-format

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitten-format - npm Package Compare versions

Comparing version 1.8.9 to 1.8.10

27

build/kittenFormat.client.js

@@ -5,3 +5,3 @@ (function (global, factory) {

(global = global || self, global.kittenFormat = factory());
}(this, function () { 'use strict';
}(this, (function () { 'use strict';

@@ -153,4 +153,4 @@ /**

*/
function format (locale$$1, value, options) {
locale$$1 = getLocale(locale$$1);
function format (locale, value, options) {
locale = getLocale(locale);

@@ -162,3 +162,3 @@ value = value + '';

let fraction = number[1] || '';
let thousandSeparator = locale$$1.thousandSeparator || ' ';
let thousandSeparator = locale.thousandSeparator || ' ';

@@ -169,3 +169,3 @@ let thousandIterator = 0;

if (fraction[fraction.length - 1] !== '0' && options.shouldNotRound !== true) {
fraction = (toFixed(Number('0.' + fraction, 10), (options.maximumFractionDigits ? options.maximumFractionDigits : locale$$1.precision)) + '');
fraction = (toFixed(Number('0.' + fraction, 10), (options.maximumFractionDigits ? options.maximumFractionDigits : locale.precision)) + '');

@@ -198,11 +198,11 @@ if (Number(fraction) === 1) {

if (fraction.length) {
res += locale$$1.decimalSeparator + fraction;
res += locale.decimalSeparator + fraction;
}
if (options.style === 'currency') {
if (locale$$1.isCurrencyFirst === true) {
res = locale$$1.currencySymbol + res;
if (locale.isCurrencyFirst === true) {
res = locale.currencySymbol + res;
}
else {
res += ' ' + locale$$1.currencySymbol;
res += ' ' + locale.currencySymbol;
}

@@ -258,3 +258,3 @@ }

function percentNumber (value, options) {
let parameters = percent(value);
let parameters = percent(value, options);

@@ -368,4 +368,5 @@ if (parameters == null || typeof parameters !== 'object') {

* @param {Number} value
* @param {Object} { isAlreadyPercentageNumber : {Boolean} }
*/
function percent (value) {
function percent (value, options) {
if (value == null) {

@@ -381,3 +382,3 @@ return value;

if (value > 1) {
if (options && options.isAlreadyPercentageNumber) {
_value = value;

@@ -512,2 +513,2 @@ }

}));
})));

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).kittenFormat=r()}(this,function(){"use strict";function e(e){return null==e||"string"!=typeof e?e:e.toLowerCase()}var r={EUR:"€",GBP:"£",CHF:"CHF",USD:"$"},t={locale:"fr-FR",currency:"EUR",currencySymbol:r.EUR,precision:2,unitPrefixes:{15:{default:"P",g:"GT"},12:{default:"T",g:"MT"},9:{default:"G",g:"kT"},6:{default:"M",g:"T"},3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","},n={default:t};function i(e){e&&(n.default=e)}function o(e){return n[e]?n[e]:n.default}function u(e,r,t){e=o(e);let n=(r+="").split("."),i=n[0],u=n[1]||"",l=e.thousandSeparator||" ",c=0,a="";"0"!==u[u.length-1]&&!0!==t.shouldNotRound&&(u=function(e,r){var t=Math.pow(10,r);return Math.round(e*t)/t}(Number("0."+u,10),t.maximumFractionDigits?t.maximumFractionDigits:e.precision)+"",1===Number(u)&&(i=Number(i)+1+""),u=u.slice(2));for(let e=i.length-1;e>=0;e--)a=i[e]+a,3===++c&&e-1>=0&&(a=l+a,c=0);if(null!=t.minimumFractionDigits)for(u+="";u.length<t.minimumFractionDigits;u+="0");return!0===t.shouldNotRound&&(u=u.slice(0,t.maximumFractionDigits?t.maximumFractionDigits:u.length)),u.length&&(a+=e.decimalSeparator+u),"currency"===t.style&&(!0===e.isCurrencyFirst?a=e.currencySymbol+a:a+=" "+e.currencySymbol),a}function l(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.shouldNotRound?r.precision:r.precision||t.precision;return{locale:r.locale||t.locale,precision:n}}(e,r);return null==t||"object"!=typeof t?t:((r=r||{}).maximumFractionDigits=t.precision,u(t.locale,e,r))}function c(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=null===(r=r||{}).power||void 0===r.power?0:r.power,n=r.unit;if(!n)return e;var i=e,u=0,l=null;if(e>=1){var c=(e+"").split(".")[0],a=c.length;u=3*Math.trunc(a/3),null!==r.maxPower&&void 0!==r.maxPower&&u+t>r.maxPower&&(l=r.maxPower-t),i=e*Math.pow(10,-(null!==l?l:u))}i<1&&(i*=Math.pow(10,3),-0===(t-=3)&&(t=0));var s=o(r.locale).unitPrefixes[(null!==l?l:u)+t];void 0===s?s="10^"+(u+t)+n:"string"!=typeof s?s=s[n]||s.default:s+=n;return{value:i,unit:s}}(e,r);return null==t||"object"!=typeof t?t:(r=r||{},(e=l(t.value,r))+" "+t.unit)}function a(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.shouldNotRound?r.precision:r.precision||t.precision,i=r.currency||r.source||t.currency,u=r.locale||t.locale;r.target&&r.rates&&r.rates[r.target]&&(r.source=i,i=r.target,e=s(e,r));return{locale:u,currency:i,precision:n,value:e,shouldNotRound:r.shouldNotRound}}(e,r);return null==t||"object"!=typeof t?t:(t.precision<2&&(t.precision=2),t.style="currency",t.minimumFractionDigits=t.precision,null==t.minimumFractionDigits&&(t.minimumFractionDigits=t.locale.precision),t.maximumFractionDigits=t.minimumFractionDigits,u(t.locale,t.value,t))}function s(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.source||t.currency,i=r.target,u=r.rates;return!i||!u||u&&!u[n]||u&&!u[i]?e:e/u[n]*u[i]}const f={};return f.setOptions=i,f.setOption=function(e,i){null!=e&&("currency"===e&&(n.default.currencySymbol=r[i]||t.currencySymbol),n.default[e]=i)},f.locale=function(e){e&&(n[e.locale]=e,i(n[e.locale]))},f.lowerCase=e,f.upperCase=function(e){return null==e||"string"!=typeof e?e:e.toUpperCase()},f.upperCaseFirstChar=function(r){return null!=r&&"string"==typeof r&&r.length?r[0].toUpperCase()+e(r.slice(1,r.length)):r},f.formatN=l,f.formatNumber=l,f.percent=function(e,r){let t=function(e){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var r=100*e;return e>1&&(r=e),{value:r}}(e);return null==t||"object"!=typeof t?t:l(t.value,r)+"%"},f.averageN=c,f.averageNumber=c,f.formatC=a,f.formatCurrency=a,f.convC=s,f.convertCurrency=s,f});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).kittenFormat=r()}(this,function(){"use strict";function e(e){return null==e||"string"!=typeof e?e:e.toLowerCase()}var r={EUR:"€",GBP:"£",CHF:"CHF",USD:"$"},t={locale:"fr-FR",currency:"EUR",currencySymbol:r.EUR,precision:2,unitPrefixes:{15:{default:"P",g:"GT"},12:{default:"T",g:"MT"},9:{default:"G",g:"kT"},6:{default:"M",g:"T"},3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","},n={default:t};function i(e){e&&(n.default=e)}function o(e){return n[e]?n[e]:n.default}function u(e,r,t){e=o(e);let n=(r+="").split("."),i=n[0],u=n[1]||"",l=e.thousandSeparator||" ",c=0,a="";"0"!==u[u.length-1]&&!0!==t.shouldNotRound&&(u=function(e,r){var t=Math.pow(10,r);return Math.round(e*t)/t}(Number("0."+u,10),t.maximumFractionDigits?t.maximumFractionDigits:e.precision)+"",1===Number(u)&&(i=Number(i)+1+""),u=u.slice(2));for(let e=i.length-1;e>=0;e--)a=i[e]+a,3===++c&&e-1>=0&&(a=l+a,c=0);if(null!=t.minimumFractionDigits)for(u+="";u.length<t.minimumFractionDigits;u+="0");return!0===t.shouldNotRound&&(u=u.slice(0,t.maximumFractionDigits?t.maximumFractionDigits:u.length)),u.length&&(a+=e.decimalSeparator+u),"currency"===t.style&&(!0===e.isCurrencyFirst?a=e.currencySymbol+a:a+=" "+e.currencySymbol),a}function l(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.shouldNotRound?r.precision:r.precision||t.precision;return{locale:r.locale||t.locale,precision:n}}(e,r);return null==t||"object"!=typeof t?t:((r=r||{}).maximumFractionDigits=t.precision,u(t.locale,e,r))}function c(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=null===(r=r||{}).power||void 0===r.power?0:r.power,n=r.unit;if(!n)return e;var i=e,u=0,l=null;if(e>=1){var c=(e+"").split(".")[0],a=c.length;u=3*Math.trunc(a/3),null!==r.maxPower&&void 0!==r.maxPower&&u+t>r.maxPower&&(l=r.maxPower-t),i=e*Math.pow(10,-(null!==l?l:u))}i<1&&(i*=Math.pow(10,3),-0===(t-=3)&&(t=0));var s=o(r.locale).unitPrefixes[(null!==l?l:u)+t];void 0===s?s="10^"+(u+t)+n:"string"!=typeof s?s=s[n]||s.default:s+=n;return{value:i,unit:s}}(e,r);return null==t||"object"!=typeof t?t:(r=r||{},(e=l(t.value,r))+" "+t.unit)}function a(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.shouldNotRound?r.precision:r.precision||t.precision,i=r.currency||r.source||t.currency,u=r.locale||t.locale;r.target&&r.rates&&r.rates[r.target]&&(r.source=i,i=r.target,e=s(e,r));return{locale:u,currency:i,precision:n,value:e,shouldNotRound:r.shouldNotRound}}(e,r);return null==t||"object"!=typeof t?t:(t.precision<2&&(t.precision=2),t.style="currency",t.minimumFractionDigits=t.precision,null==t.minimumFractionDigits&&(t.minimumFractionDigits=t.locale.precision),t.maximumFractionDigits=t.minimumFractionDigits,u(t.locale,t.value,t))}function s(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=o((r=r||{}).locale),n=r.source||t.currency,i=r.target,u=r.rates;return!i||!u||u&&!u[n]||u&&!u[i]?e:e/u[n]*u[i]}const f={};return f.setOptions=i,f.setOption=function(e,i){null!=e&&("currency"===e&&(n.default.currencySymbol=r[i]||t.currencySymbol),n.default[e]=i)},f.locale=function(e){e&&(n[e.locale]=e,i(n[e.locale]))},f.lowerCase=e,f.upperCase=function(e){return null==e||"string"!=typeof e?e:e.toUpperCase()},f.upperCaseFirstChar=function(r){return null!=r&&"string"==typeof r&&r.length?r[0].toUpperCase()+e(r.slice(1,r.length)):r},f.formatN=l,f.formatNumber=l,f.percent=function(e,r){let t=function(e,r){if(null==e)return e;if("string"==typeof e&&isNaN(e))return"-";var t=100*e;return r&&r.isAlreadyPercentageNumber&&(t=e),{value:t}}(e,r);return null==t||"object"!=typeof t?t:l(t.value,r)+"%"},f.averageN=c,f.averageNumber=c,f.formatC=a,f.formatCurrency=a,f.convC=s,f.convertCurrency=s,f});

@@ -148,4 +148,4 @@ 'use strict';

*/
function format (locale$$1, value, options) {
locale$$1 = getLocale(locale$$1);
function format (locale, value, options) {
locale = getLocale(locale);

@@ -157,3 +157,3 @@ value = value + '';

let fraction = number[1] || '';
let thousandSeparator = locale$$1.thousandSeparator || ' ';
let thousandSeparator = locale.thousandSeparator || ' ';

@@ -164,3 +164,3 @@ let thousandIterator = 0;

if (fraction[fraction.length - 1] !== '0' && options.shouldNotRound !== true) {
fraction = (toFixed(Number('0.' + fraction, 10), (options.maximumFractionDigits ? options.maximumFractionDigits : locale$$1.precision)) + '');
fraction = (toFixed(Number('0.' + fraction, 10), (options.maximumFractionDigits ? options.maximumFractionDigits : locale.precision)) + '');

@@ -193,11 +193,11 @@ if (Number(fraction) === 1) {

if (fraction.length) {
res += locale$$1.decimalSeparator + fraction;
res += locale.decimalSeparator + fraction;
}
if (options.style === 'currency') {
if (locale$$1.isCurrencyFirst === true) {
res = locale$$1.currencySymbol + res;
if (locale.isCurrencyFirst === true) {
res = locale.currencySymbol + res;
}
else {
res += ' ' + locale$$1.currencySymbol;
res += ' ' + locale.currencySymbol;
}

@@ -253,3 +253,3 @@ }

function percentNumber (value, options) {
let parameters = percent(value);
let parameters = percent(value, options);

@@ -363,4 +363,5 @@ if (parameters == null || typeof parameters !== 'object') {

* @param {Number} value
* @param {Object} { isAlreadyPercentageNumber : {Boolean} }
*/
function percent (value) {
function percent (value, options) {
if (value == null) {

@@ -376,3 +377,3 @@ return value;

if (value > 1) {
if (options && options.isAlreadyPercentageNumber) {
_value = value;

@@ -379,0 +380,0 @@ }

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_de_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"de-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_de_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"de-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_en_GB=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"en-GB",currency:"GBP",currencySymbol:"£",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:",",decimalSeparator:".",isCurrencyFirst:!0};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_en_GB=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"en-GB",currency:"GBP",currencySymbol:"£",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:",",decimalSeparator:".",isCurrencyFirst:!0};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_es_ES=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"es-ES",currency:"EUR",currencySymbol:"€",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_es_ES=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"es-ES",currency:"EUR",currencySymbol:"€",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_fr_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"fr-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_fr_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"fr-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_fr_FR=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"fr-FR",currency:"EUR",currencySymbol:"€",precision:2,unitPrefixes:{15:{default:"P",g:"GT"},12:{default:"T",g:"MT"},9:{default:"G",g:"kT"},6:{default:"M",g:"T"},3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_fr_FR=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"fr-FR",currency:"EUR",currencySymbol:"€",precision:2,unitPrefixes:{15:{default:"P",g:"GT"},12:{default:"T",g:"MT"},9:{default:"G",g:"kT"},6:{default:"M",g:"T"},3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_it_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"it-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&e.hasOwnProperty("default")?e.default:e).locale(t),t});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kitten-format")):"function"==typeof define&&define.amd?define(["kitten-format"],t):(e=e||self).kittenFormat_it_CH=t(e.kittenFormat)}(this,function(e){"use strict";var t={locale:"it-CH",currency:"CHF",currencySymbol:"CHF",precision:2,unitPrefixes:{15:"P",12:"T",9:"G",6:"M",3:"k",0:"","-3":"m","-6":"μ","-9":"n"},thousandSeparator:" ",decimalSeparator:","};return(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).locale(t),t});

@@ -142,3 +142,3 @@ # kitten-format

kittenFormat.percent(18.45);
kittenFormat.percent(18.45, { isAlreadyPercentageNumber : true });

@@ -145,0 +145,0 @@ // res: '18,45%'

@@ -48,3 +48,3 @@ import { getLocale } from './options';

export function percentNumber (value, options) {
let parameters = percent(value);
let parameters = percent(value, options);

@@ -158,4 +158,5 @@ if (parameters == null || typeof parameters !== 'object') {

* @param {Number} value
* @param {Object} { isAlreadyPercentageNumber : {Boolean} }
*/
export function percent (value) {
export function percent (value, options) {
if (value == null) {

@@ -171,3 +172,3 @@ return value;

if (value > 1) {
if (options && options.isAlreadyPercentageNumber) {
_value = value;

@@ -174,0 +175,0 @@ }

{
"name": "kitten-format",
"version": "1.8.9",
"version": "1.8.10",
"description": "Fast formatters for browsers",

@@ -5,0 +5,0 @@ "main": "build/kittenFormat.server.js",

@@ -142,3 +142,3 @@ # kitten-format

kittenFormat.percent(18.45);
kittenFormat.percent(18.45, { isAlreadyPercentageNumber : true });

@@ -145,0 +145,0 @@ // res: '18,45%'

@@ -434,3 +434,3 @@ const should = require('should');

it('should set percentage of a string', () => {
should(kittenFormat.percent('123')).eql('123%');
should(kittenFormat.percent('0.1')).eql('10%');
});

@@ -457,6 +457,27 @@

it('should set percentage of a number > 1', () => {
should(sanitizeSpaces(kittenFormat.percent(12.56))).eql('12,56%');
it('should set percentage of a number = 1', () => {
should(sanitizeSpaces(kittenFormat.percent(1))).eql('100%');
});
it('should set percentage of a number > 1 with isAlreadyPercentageNumber', () => {
var _options = {
isAlreadyPercentageNumber : true
};
should(sanitizeSpaces(kittenFormat.percent(12.56, _options))).eql('12,56%');
});
it('should set percentage of a number = 1 with isAlreadyPercentageNumber', () => {
var _options = {
isAlreadyPercentageNumber : true
};
should(sanitizeSpaces(kittenFormat.percent(1, _options))).eql('1%');
});
it('should set percentage of a string of a number > 1 with isAlreadyPercentageNumber', () => {
var _options = {
isAlreadyPercentageNumber : true
};
should(kittenFormat.percent('123', _options)).eql('123%');
});
it('should be fast', () => {

@@ -463,0 +484,0 @@ var _locales = ['fr-FR', 'fr-CHF', 'en-GB'];

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