@alfalab/utils
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -1,2 +0,2 @@ | ||
// Generated by dts-bundle-generator v5.3.0 | ||
// Generated by dts-bundle-generator v5.4.0 | ||
@@ -57,3 +57,15 @@ import { CurrencyCodes } from '@alfalab/data'; | ||
export declare function pluralize(number: number, one: string, two: string, five: string): string; | ||
export declare type Country = { | ||
name: string; | ||
iso2: string; | ||
dialCode: string; | ||
priority?: number; | ||
areaCodes: string[] | null; | ||
}; | ||
export declare type CountriesHash = { | ||
[iso2: string]: Country; | ||
}; | ||
export declare const getCountries: () => Country[]; | ||
export declare const getCountriesHash: () => CountriesHash; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data"),e=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var t=function(e){return r.currency.CURRENCY_SYMBOLS[e]},o=String.fromCharCode(8201);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,n=r.currency,a=r.minority,u=r.view;if(null===e)return{majorPart:"",minorPart:"",formated:"",currencySymbol:t(n),formatedWithCurrency:o+t(n)};a=0===a?1:a;var c=Math.log(a)*Math.LOG10E,i=(Math.abs(e)/a).toFixed(c),l=i.split(".")[0],d=i.split(".")[1];"default"===u&&e%a==0&&(d="");var s=function(r,e,t,o){void 0===e&&(e=3),void 0===o&&(o=5);var n="\\B(?=(\\d{"+e+"})+(?!\\d))";return r.length<o?r:r.replace(new RegExp(n,"g"),t)}(l,3,o,4),f=e<0?"−"+s:s,m=d?f+","+d:f;return{majorPart:f,minorPart:d,currencySymbol:t(n),formated:m,formatedWithCurrency:m+o+t(n)}},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCurrencySymbol=t,exports.pluralize=function(r,e,t,o){var n=Math.abs(r);return(n%=100)>=5&&n<=20?o:1===(n%=10)?e:n>=2&&n<=4?t:o}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@alfalab/data"),e=/^(\d{5})(\d{3})(\d)(\d{4})(\d{7})$/;var t=function(e){return r.currency.CURRENCY_SYMBOLS[e]},n=String.fromCharCode(8201);var o=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}};exports.AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR=",",exports.THINSP=n,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,o=r.currency,u=r.minority,a=r.view;if(null===e)return{majorPart:"",minorPart:"",formated:"",currencySymbol:t(o),formatedWithCurrency:n+t(o)};u=0===u?1:u;var c=Math.log(u)*Math.LOG10E,i=(Math.abs(e)/u).toFixed(c),l=i.split(".")[0],s=i.split(".")[1];"default"===a&&e%u==0&&(s="");var d=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)}(l,3,n,4),f=e<0?"−"+d:d,m=s?f+","+s:f;return{majorPart:f,minorPart:s,currencySymbol:t(o),formated:m,formatedWithCurrency:m+n+t(o)}},exports.getAllCurrencyCodes=function(){return Object.keys(r.currency.CURRENCY_SYMBOLS)},exports.getCountries=function(){return r.countries.map(o).sort((function(r,e){return r.name.localeCompare(e.name)}))},exports.getCountriesHash=function(){return r.countries.reduce((function(r,e){return r[e[2]]=o(e),r}),{})},exports.getCurrencySymbol=t,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}; |
{ | ||
"name": "@alfalab/utils", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "common utils", | ||
@@ -19,7 +19,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@alfalab/data": "^0.1.0", | ||
"dts-bundle-generator": "^5.3.0" | ||
"@alfalab/data": "^0.2.0", | ||
"dts-bundle-generator": "^5.4.0" | ||
}, | ||
"peerDependencies": { | ||
"@alfalab/data": "^0.1.0" | ||
"@alfalab/data": "^0.2.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "publishConfig": { |
@@ -1,1 +0,8 @@ | ||
# Utils | ||
# Utils | ||
### get-countries | ||
утилиты для работы со странами: | ||
- getCountries - вернет массив объектов Country; | ||
- getCountriesMap - вернет объект, где ключ объекта - код страны (iso2), значение - объект Country; |
4860
74
9