@alfalab/utils
Advanced tools
Comparing version 1.2.1 to 1.3.0
// Generated by dts-bundle-generator v5.8.0 | ||
/// <reference types="react" /> | ||
/** | ||
@@ -203,2 +205,7 @@ * Возвращает 4 последние цифры номера счёта в формате `··XXXX` | ||
export declare const getCurrencySymbol: (currencyCode: CurrencyCodes) => string; | ||
/** | ||
* Возвращает `true`, если элемент переполнен | ||
* @param element HTML-элемент | ||
*/ | ||
export declare function isOverflown(element: HTMLElement): boolean; | ||
export declare function pluralize(number: number, one: string, two: string, five: string): string; | ||
@@ -205,0 +212,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data");var t=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var e=function(t){return r.currency.CURRENCY_SYMBOLS[t]},n=function(r,t,e,n){void 0===t&&(t=3),void 0===n&&(n=5);var o="\\B(?=(\\d{"+t+"})+(?!\\d))";return r.length<n?r:r.replace(new RegExp(o,"g"),e)},o=String.fromCharCode(8201),u=["B","KB","MB","GB"],a=function(r){return r.replace(/\D+/g,"")};var c={format:function(r){var t=a(r).replace(/(\d)(\d{3})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3-$4-$5");return"7"===t[0]?"+".concat(t):t},getRaw:a,mask:function(r){return r.substr(0,2)+" ··· ··· "+r.substr(r.length-5,r.length)}};var i=function(r){r[0];var t=r[1],e=r[2],n=r[3],o=r[4],u=r[5];return{name:t,iso2:e,dialCode:n,priority:o,areaCodes:null!=u?u:null}};function s(r,t){return void 0===t?r:(r+t).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(t,"$1 $2 $3 $4 $5"):""},exports.formatAmount=function(r){var t=r.value,u=r.currency,a=r.minority,c=r.view;if(null===t)return{majorPart:"",minorPart:"",formatted:"",currencySymbol:e(u),formattedWithCurrency:o+e(u)};a=0===a?1:a;var i=Math.log(a)*Math.LOG10E,s=(Math.abs(t)/a).toFixed(i),l=s.split(".")[0],f=s.split(".")[1];"default"===c&&t%a==0&&(f="");var d=n(l,3,o,4),m=t<0?"−"+d:d,p=f?m+","+f:m;return{majorPart:m,minorPart:f,currencySymbol:e(u),formatted:p,formattedWithCurrency:p+o+e(u)}},exports.formatFileSize=function(r){for(var t=u.length-1,e=function(r){var t=Number(r);return Number.isNaN(t)?0:t}(r),n=0;e>=1024&&n<t;)e/=1024,n+=1;return function(r,t){return r>99&&t===u.length-1?"99+":""+Number(r.toFixed(2))}(e,n)+" "+u[n]},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCountries=function(){return r.countries.map(i).sort((function(r,t){return r.name.localeCompare(t.name)}))},exports.getCountriesHash=function(){return r.countries.reduce((function(r,t){return r[t[2]]=i(t),r}),{})},exports.getCurrencySymbol=e,exports.phoneNumber=c,exports.pluralize=function(r,t,e,n){var o=Math.abs(r);return(o%=100)>=5&&o<=20?n:1===(o%=10)?t:o>=2&&o<=4?e:n},exports.secondsToTime=function(r){var t=Math.floor(r/60/60),e=Math.floor(r/60)%60,n=r-3600*t-60*e;return{hours:""+s("00",t),minutes:""+s("00",e),seconds:""+s("00",n)}},exports.splitAmount=n; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data");var t=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var e=function(t){return r.currency.CURRENCY_SYMBOLS[t]},n=function(r,t,e,n){void 0===t&&(t=3),void 0===n&&(n=5);var o="\\B(?=(\\d{"+t+"})+(?!\\d))";return r.length<n?r:r.replace(new RegExp(o,"g"),e)},o=String.fromCharCode(8201),u=["B","KB","MB","GB"],a=function(r){return r.replace(/\D+/g,"")};var i={format:function(r){var t=a(r).replace(/(\d)(\d{3})(\d{3})(\d{2})(\d{2})/,"$1 $2 $3-$4-$5");return"7"===t[0]?"+".concat(t):t},getRaw:a,mask:function(r){return r.substr(0,2)+" ··· ··· "+r.substr(r.length-5,r.length)}};var c=function(r){r[0];var t=r[1],e=r[2],n=r[3],o=r[4],u=r[5];return{name:t,iso2:e,dialCode:n,priority:o,areaCodes:null!=u?u:null}};function s(r,t){return void 0===t?r:(r+t).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(t,"$1 $2 $3 $4 $5"):""},exports.formatAmount=function(r){var t=r.value,u=r.currency,a=r.minority,i=r.view;if(null===t)return{majorPart:"",minorPart:"",formatted:"",currencySymbol:e(u),formattedWithCurrency:o+e(u)};a=0===a?1:a;var c=Math.log(a)*Math.LOG10E,s=(Math.abs(t)/a).toFixed(c),l=s.split(".")[0],f=s.split(".")[1];"default"===i&&t%a==0&&(f="");var d=n(l,3,o,4),m=t<0?"−"+d:d,p=f?m+","+f:m;return{majorPart:m,minorPart:f,currencySymbol:e(u),formatted:p,formattedWithCurrency:p+o+e(u)}},exports.formatFileSize=function(r){for(var t=u.length-1,e=function(r){var t=Number(r);return Number.isNaN(t)?0:t}(r),n=0;e>=1024&&n<t;)e/=1024,n+=1;return function(r,t){return r>99&&t===u.length-1?"99+":""+Number(r.toFixed(2))}(e,n)+" "+u[n]},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCountries=function(){return r.countries.map(c).sort((function(r,t){return r.name.localeCompare(t.name)}))},exports.getCountriesHash=function(){return r.countries.reduce((function(r,t){return r[t[2]]=c(t),r}),{})},exports.getCurrencySymbol=e,exports.isOverflown=function(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth},exports.phoneNumber=i,exports.pluralize=function(r,t,e,n){var o=Math.abs(r);return(o%=100)>=5&&o<=20?n:1===(o%=10)?t:o>=2&&o<=4?e:n},exports.secondsToTime=function(r){var t=Math.floor(r/60/60),e=Math.floor(r/60)%60,n=r-3600*t-60*e;return{hours:""+s("00",t),minutes:""+s("00",e),seconds:""+s("00",n)}},exports.splitAmount=n; |
{ | ||
"name": "@alfalab/utils", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "common utils", | ||
@@ -29,3 +29,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "b2f99c9b3125b88d1b594094ce18df7abb666bf3" | ||
"gitHead": "0c1526ec4823a6e003f58d1d2cfba50c5abcd660" | ||
} |
@@ -9,1 +9,5 @@ # Utils | ||
- getCountriesMap - вернет объект, где ключ объекта - код страны (iso2), значение - объект Country; | ||
### is-overflown | ||
- `isOverflown` - возвращает `true`, если html-элемент переполнен. Необходимо в случаях когда надо определить, есть ли у элемента скроллбар или текст в элементе обрезался (`text-overflow`). |
9916
238
13