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.7 to 1.8.8

8

build/kittenFormat.client.js

@@ -175,3 +175,9 @@ (function (global, factory) {

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

@@ -178,0 +184,0 @@

2

build/kittenFormat.client.min.js

@@ -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="";for(let e=i.length-1;e>=0;e--)a=i[e]+a,3===++c&&e-1>=0&&(a=l+a,c=0);if("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)+"").slice(2)),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="";for(let e=i.length-1;e>=0;e--)a=i[e]+a,3===++c&&e-1>=0&&(a=l+a,c=0);if("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)&&(a=Number(a)+1+""),u=u.slice(2)),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});

@@ -171,3 +171,9 @@ 'use strict';

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

@@ -174,0 +180,0 @@

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

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

@@ -39,0 +45,0 @@

{
"name": "kitten-format",
"version": "1.8.7",
"version": "1.8.8",
"description": "Fast formatters for browsers",

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

@@ -113,2 +113,8 @@ const should = require('should');

it('should format decimal number rounding to next integer at precision 2', () => {
should(kittenFormat.formatN('14.9999', {
precision : 2
})).eql('15');
})
it('should format a number with minimumFractionDigits', () => {

@@ -115,0 +121,0 @@ should(kittenFormat.formatN('14.4596', {

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