@alfalab/utils
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.5.1](https://github.com/alfa-laboratory/utils/compare/@alfalab/utils@1.5.0...@alfalab/utils@1.5.1) (2021-11-25) | ||
### Bug Fixes | ||
* **utils:** fix formatAmount unknown currency ([#74](https://github.com/alfa-laboratory/utils/issues/74)) ([f053f21](https://github.com/alfa-laboratory/utils/commit/f053f21d76c0c62f8164ce7b5c59630bdd8b15e3)) | ||
# [1.5.0](https://github.com/alfa-laboratory/utils/compare/@alfalab/utils@1.4.5...@alfalab/utils@1.5.0) (2021-10-04) | ||
@@ -8,0 +19,0 @@ |
@@ -160,3 +160,3 @@ // Generated by dts-bundle-generator v5.8.0 | ||
*/ | ||
export declare const formatAmount: ({ value, currency, minority, view, }: AmountType) => { | ||
export declare const formatAmount: ({ value, currency, minority, view }: AmountType) => { | ||
majorPart: string; | ||
@@ -163,0 +163,0 @@ minorPart: string; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data");var e=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var t=function(e){return r.currency.CURRENCY_SYMBOLS[e]},n=function(r,e,t,n){void 0===e&&(e=3),void 0===n&&(n=5);var o="\\B(?=(\\d{"+e+"})+(?!\\d))";return r.length<n?r:r.replace(new RegExp(o,"g"),t)},o=String.fromCharCode(8201),u=["B","KB","MB","GB"],a=function(r){return r.replace(/\D+/g,"")};var i={format:function(r){var e=a(r).replace(/(\d)(\d{3})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3-$4-$5");return"7"===e[0]?"+".concat(e):e},getRaw:a,mask:function(r){return r.substr(0,2)+" ··· ··· "+r.substr(r.length-5,r.length)}};var c=function(r){r[0];var e=r[1],t=r[2],n=r[3],o=r[4],u=r[5];return{name:e,iso2:t,dialCode:n,priority:o,areaCodes:null!=u?u:null}};function s(r,e){return void 0===e?r:(r+e).slice(-r.length)}exports.AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR=",",exports.THINSP=o,exports.cropAccountNumber=function(r){return r?"··"+r.slice(-4):r},exports.formatAccount=function(r){return r?r.replace(e,"$1 $2 $3 $4 $5"):""},exports.formatAmount=function(r){var e=r.value,u=r.currency,a=r.minority,i=r.view;if(null===e)return{majorPart:"",minorPart:"",formatted:"",currencySymbol:t(u),formattedWithCurrency:o+t(u)};a=0===a?1:a;var c=Math.log(a)*Math.LOG10E,s=(Math.abs(e)/a).toFixed(c),l=s.split(".")[0],f=s.split(".")[1];"default"===i&&e%a==0&&(f="");var d=n(l,3,o,4),m=e<0?"−"+d:d,p=f?m+","+f:m;return{majorPart:m,minorPart:f,currencySymbol:t(u),formatted:p,formattedWithCurrency:p+o+t(u)}},exports.formatFileSize=function(r){for(var e=u.length-1,t=function(r){var e=Number(r);return Number.isNaN(e)?0:e}(r),n=0;t>=1024&&n<e;)t/=1024,n+=1;return function(r,e){return r>99&&e===u.length-1?"99+":""+Number(r.toFixed(2))}(t,n)+" "+u[n]},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCountries=function(){return r.countries.map(c).sort((function(r,e){return r.name.localeCompare(e.name)}))},exports.getCountriesHash=function(){return r.countries.reduce((function(r,e){return r[e[2]]=c(e),r}),{})},exports.getCurrencySymbol=t,exports.hasScrolledToBottomOfPage=function(){var r=document.documentElement;return r.scrollTop+window.innerHeight>=r.offsetHeight},exports.isOverflown=function(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth},exports.isValidCardNumber=function(r){var e=0,t=r.replace(/\D/g,"");if(""===t)return!1;for(var n=0;n<t.length;n++){var o=parseInt(t[n],10);e+=0==n%2&&(o*=2)>9?o-9:o}return e%10==0},exports.phoneNumber=i,exports.pluralize=function(r,e,t,n){var o=Math.abs(r);return(o%=100)>=5&&o<=20?n:1===(o%=10)?e:o>=2&&o<=4?t:n},exports.secondsToTime=function(r){var e=Math.floor(r/60/60),t=Math.floor(r/60)%60,n=r-3600*e-60*t;return{hours:""+s("00",e),minutes:""+s("00",t),seconds:""+s("00",n)}},exports.splitAmount=n; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data");var e=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var t=function(e){return r.currency.CURRENCY_SYMBOLS[e]},n=function(r,e,t,n){void 0===e&&(e=3),void 0===n&&(n=5);var o="\\B(?=(\\d{"+e+"})+(?!\\d))";return r.length<n?r:r.replace(new RegExp(o,"g"),t)},o=String.fromCharCode(8201),u=function(r,e){return[r,e].filter(Boolean).join(o)},a=["B","KB","MB","GB"],i=function(r){return r.replace(/\D+/g,"")};var c={format:function(r){var e=i(r).replace(/(\d)(\d{3})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3-$4-$5");return"7"===e[0]?"+".concat(e):e},getRaw:i,mask:function(r){return r.substr(0,2)+" ··· ··· "+r.substr(r.length-5,r.length)}};var l=function(r){r[0];var e=r[1],t=r[2],n=r[3],o=r[4],u=r[5];return{name:e,iso2:t,dialCode:n,priority:o,areaCodes:null!=u?u:null}};function s(r,e){return void 0===e?r:(r+e).slice(-r.length)}exports.AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR=",",exports.THINSP=o,exports.cropAccountNumber=function(r){return r?"··"+r.slice(-4):r},exports.formatAccount=function(r){return r?r.replace(e,"$1 $2 $3 $4 $5"):""},exports.formatAmount=function(r){var e=r.value,a=r.currency,i=r.minority,c=r.view,l=t(a);if(null===e)return{majorPart:"",minorPart:"",formatted:"",currencySymbol:l,formattedWithCurrency:u(e,l)};i=0===i?1:i;var s=Math.log(i)*Math.LOG10E,f=(Math.abs(e)/i).toFixed(s),d=f.split(".")[0],m=f.split(".")[1];"default"===c&&e%i==0&&(m="");var p=n(d,3,o,4),h=e<0?"−"+p:p,v=m?h+","+m:h;return{majorPart:h,minorPart:m,currencySymbol:l,formatted:v,formattedWithCurrency:u(v,l)}},exports.formatFileSize=function(r){for(var e=a.length-1,t=function(r){var e=Number(r);return Number.isNaN(e)?0:e}(r),n=0;t>=1024&&n<e;)t/=1024,n+=1;return function(r,e){return r>99&&e===a.length-1?"99+":""+Number(r.toFixed(2))}(t,n)+" "+a[n]},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCountries=function(){return r.countries.map(l).sort((function(r,e){return r.name.localeCompare(e.name)}))},exports.getCountriesHash=function(){return r.countries.reduce((function(r,e){return r[e[2]]=l(e),r}),{})},exports.getCurrencySymbol=t,exports.hasScrolledToBottomOfPage=function(){var r=document.documentElement;return r.scrollTop+window.innerHeight>=r.offsetHeight},exports.isOverflown=function(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth},exports.isValidCardNumber=function(r){var e=0,t=r.replace(/\D/g,"");if(""===t)return!1;for(var n=0;n<t.length;n++){var o=parseInt(t[n],10);e+=0==n%2&&(o*=2)>9?o-9:o}return e%10==0},exports.phoneNumber=c,exports.pluralize=function(r,e,t,n){var o=Math.abs(r);return(o%=100)>=5&&o<=20?n:1===(o%=10)?e:o>=2&&o<=4?t:n},exports.secondsToTime=function(r){var e=Math.floor(r/60/60),t=Math.floor(r/60)%60,n=r-3600*e-60*t;return{hours:""+s("00",e),minutes:""+s("00",t),seconds:""+s("00",n)}},exports.splitAmount=n; |
{ | ||
"name": "@alfalab/utils", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "common utils", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "0f5f9fa3f07e21cf1813b9204ef0b2c5f6a2b27d" | ||
"gitHead": "7344be6a187410a248cb3d45c63715f856b372fd" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15854
248