@bodar/totallylazy
Advanced tools
Comparing version 0.390.231 to 0.391.232
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.additionalSymbols = [{ | ||
iso: 'KES', symbol: 'KSh' | ||
}]; | ||
exports.additionalSymbols = [ | ||
{ iso: 'KES', symbol: 'KSh' }, | ||
{ iso: 'EEK', symbol: 'kr' }, | ||
]; |
@@ -1054,3 +1054,9 @@ "use strict"; | ||
"symbols": [] | ||
}, | ||
"EEK": { | ||
"symbols": [ | ||
"kr" | ||
], | ||
"decimals": 2 | ||
} | ||
}; |
@@ -13,3 +13,3 @@ "use strict"; | ||
(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var symbols, currencies, _a, _b, _c; | ||
var symbols, currencies, _a, _b, _c, allCurrencies; | ||
return tslib_1.__generator(this, function (_d) { | ||
@@ -19,3 +19,3 @@ switch (_d.label) { | ||
case 1: | ||
symbols = tslib_1.__spread.apply(void 0, [_d.sent(), currencies_def_1.additionalSymbols]); | ||
symbols = _d.sent(); | ||
_b = (_a = symbols).reduce; | ||
@@ -31,3 +31,10 @@ _c = [function (c, s) { | ||
currencies = _b.apply(_a, _c.concat([_d.sent()])); | ||
return [4 /*yield*/, generateFile(currencies)]; | ||
allCurrencies = currencies_def_1.additionalSymbols.reduce(function (c, s) { | ||
var currency = c[s.iso] || { symbols: [], decimals: 2 }; | ||
if (!currency.symbols.includes(s.symbol)) | ||
currency.symbols.push(s.symbol); | ||
c[s.iso] = currency; | ||
return c; | ||
}, currencies); | ||
return [4 /*yield*/, generateFile(allCurrencies)]; | ||
case 3: | ||
@@ -34,0 +41,0 @@ _d.sent(); |
@@ -71,6 +71,7 @@ import { NamedMatch } from "../characters"; | ||
export declare class CurrencySymbols extends DatumLookup<string> { | ||
private locale; | ||
static cache: { | ||
[key: string]: CurrencySymbols; | ||
}; | ||
constructor(data: Datum<string>[]); | ||
constructor(data: Datum<string>[], locale: string); | ||
static get(locale: string, additionalData?: CurrencySymbolDatum[]): CurrencySymbols; | ||
@@ -82,2 +83,3 @@ static set(locale: string, months: CurrencySymbols): CurrencySymbols; | ||
static dataFor(locale: string, iso: string, currency: Currency): CurrencySymbolDatum[]; | ||
static readonly extraDelimiters: RegExp; | ||
parse(value: string, strategy?: MatchStrategy<string>): string; | ||
@@ -84,0 +86,0 @@ } |
@@ -116,4 +116,8 @@ "use strict"; | ||
tslib_1.__extends(CurrencySymbols, _super); | ||
function CurrencySymbols(data) { | ||
return _super.call(this, data, collections_1.ascending) || this; | ||
function CurrencySymbols(data, locale) { | ||
var _this = _super.call(this, data.map(function (d) { | ||
return ({ name: d.name.replace(CurrencySymbols.extraDelimiters, ''), value: d.value }); | ||
}), collections_1.ascending) || this; | ||
_this.locale = locale; | ||
return _this; | ||
} | ||
@@ -129,3 +133,3 @@ CurrencySymbols.get = function (locale, additionalData) { | ||
if (additionalData === void 0) { additionalData = []; } | ||
return new CurrencySymbols(tslib_1.__spread(CurrencySymbols.generateData(locale), additionalData)); | ||
return new CurrencySymbols(tslib_1.__spread(CurrencySymbols.generateData(locale), additionalData), locale); | ||
}; | ||
@@ -148,7 +152,8 @@ CurrencySymbols.generateData = function (locale) { | ||
CurrencySymbols.prototype.parse = function (value, strategy) { | ||
if (strategy === void 0) { strategy = parsing_1.prefer('GBP'); } | ||
return _super.prototype.parse.call(this, value, strategy); | ||
if (strategy === void 0) { strategy = parsing_1.infer(this.locale); } | ||
return _super.prototype.parse.call(this, value.replace(CurrencySymbols.extraDelimiters, ''), strategy); | ||
}; | ||
CurrencySymbols.cache = {}; | ||
CurrencySymbols.generateAdditionalSymbols = ['$', '¥', '£']; | ||
CurrencySymbols.extraDelimiters = new RegExp("[" + parsing_1.boundaryDelimiters + "]$"); | ||
return CurrencySymbols; | ||
@@ -155,0 +160,0 @@ }(dates_1.DatumLookup)); |
export declare class PreferredCurrencies { | ||
static dollarCountries: { | ||
[country: string]: string; | ||
}; | ||
/** | ||
@@ -6,2 +9,5 @@ * https://en.wikipedia.org/wiki/Dollar#Economies_that_use_a_dollar | ||
static dollarSymbol(country?: string): string; | ||
static poundCountries: { | ||
[country: string]: string; | ||
}; | ||
/** | ||
@@ -11,4 +17,11 @@ * https://en.wikipedia.org/wiki/Pound_(currency)#Countries_and_territories_currently_using_currencies_called_pounds | ||
static poundSymbol(country?: string): string; | ||
static yenCountries: { | ||
[country: string]: string; | ||
}; | ||
static yenSymbol(country?: string): string; | ||
static kroneCountries: { | ||
[country: string]: string; | ||
}; | ||
static kroneSymbol(country?: string): string; | ||
static for(country?: string): string[]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var currencies_1 = require("./currencies"); | ||
var PreferredCurrencies = /** @class */ (function () { | ||
@@ -11,22 +10,3 @@ function PreferredCurrencies() { | ||
PreferredCurrencies.dollarSymbol = function (country) { | ||
var code = (function () { | ||
switch (country) { | ||
case 'AG': | ||
case 'DM': | ||
case 'GD': | ||
case 'KN': | ||
case 'LC': | ||
case 'VC': | ||
return 'XCD'; | ||
case 'KI': | ||
case 'TV': | ||
return 'AUD'; | ||
default: | ||
return country + "D"; | ||
} | ||
})(); | ||
var currency = currencies_1.currencies[code]; | ||
if (!currency) | ||
return 'USD'; | ||
return code; | ||
return (country && PreferredCurrencies.dollarCountries[country]) || 'USD'; | ||
}; | ||
@@ -37,32 +17,81 @@ /** | ||
PreferredCurrencies.poundSymbol = function (country) { | ||
var code = (function () { | ||
switch (country) { | ||
case 'SD': | ||
return 'SDG'; | ||
default: | ||
return country + "P"; | ||
} | ||
})(); | ||
var currency = currencies_1.currencies[code]; | ||
if (!currency) | ||
return 'GBP'; | ||
return code; | ||
return (country && PreferredCurrencies.poundCountries[country]) || 'GBP'; | ||
}; | ||
PreferredCurrencies.yenSymbol = function (country) { | ||
var code = (function () { | ||
switch (country) { | ||
default: | ||
return country + "Y"; | ||
} | ||
})(); | ||
var currency = currencies_1.currencies[code]; | ||
if (!currency) | ||
return 'JPY'; | ||
return code; | ||
return (country && PreferredCurrencies.yenCountries[country]) || 'JPY'; | ||
}; | ||
PreferredCurrencies.kroneSymbol = function (country) { | ||
return (country && PreferredCurrencies.kroneCountries[country]) || 'DKK'; | ||
}; | ||
PreferredCurrencies.for = function (country) { | ||
return [PreferredCurrencies.dollarSymbol(country), PreferredCurrencies.poundSymbol(country), PreferredCurrencies.yenSymbol(country)]; | ||
return [ | ||
PreferredCurrencies.dollarSymbol(country), | ||
PreferredCurrencies.poundSymbol(country), | ||
PreferredCurrencies.yenSymbol(country), | ||
PreferredCurrencies.kroneSymbol(country) | ||
]; | ||
}; | ||
PreferredCurrencies.dollarCountries = { | ||
'AG': 'XCD', | ||
'AU': 'AUD', | ||
'BS': 'BSD', | ||
'BB': 'BBD', | ||
'BZ': 'BZD', | ||
'BM': 'BMD', | ||
'BN': 'BND', | ||
'CA': 'CAD', | ||
'DM': 'XCD', | ||
'EC': 'USD', | ||
'FM': 'USD', | ||
'KY': 'KYD', | ||
'FJ': 'FJD', | ||
'GD': 'XCD', | ||
'GY': 'GYD', | ||
'HK': 'HKD', | ||
'JM': 'JMD', | ||
'KI': 'AUD', | ||
'KN': 'XCD', | ||
'LC': 'XCD', | ||
'LR': 'LRD', | ||
'MH': 'USD', | ||
'NA': 'NAD', | ||
'NZ': 'NZD', | ||
'SG': 'SGD', | ||
'SB': 'SBD', | ||
'SR': 'SRD', | ||
'SV': 'USD', | ||
'TL': 'USD', | ||
'TW': 'TWD', | ||
'TT': 'TTD', | ||
'TV': 'AUD', | ||
'VC': 'XCD', | ||
'ZW': 'USD', | ||
}; | ||
PreferredCurrencies.poundCountries = { | ||
'EG': 'EGP', | ||
'FK': 'FKP', | ||
'GI': 'GIP', | ||
'GG': 'GBP', | ||
'IM': 'GBP', | ||
'JE': 'GBP', | ||
'LB': 'LBP', | ||
'SH': 'SHP', | ||
'SS': 'SSP', | ||
'SD': 'SDG', | ||
'SY': 'SYP', | ||
}; | ||
PreferredCurrencies.yenCountries = { | ||
'CN': 'CNY', | ||
}; | ||
PreferredCurrencies.kroneCountries = { | ||
'DK': 'DKK', | ||
'FO': 'DKK', | ||
'GL': 'DKK', | ||
'IS': 'ISK', | ||
'NO': 'NOK', | ||
'SE': 'SEK', | ||
'EE': 'EEK', | ||
}; | ||
return PreferredCurrencies; | ||
}()); | ||
exports.PreferredCurrencies = PreferredCurrencies; |
{ | ||
"name": "@bodar/totallylazy", | ||
"version": "0.390.231", | ||
"version": "0.391.232", | ||
"description": "Totallylazy", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:bodar/totallylazy.js.git", |
@@ -68,2 +68,3 @@ import { NamedMatch, NamedRegExp } from "./characters"; | ||
} | ||
export declare const boundaryDelimiters = ",."; | ||
export declare function atBoundaryOnly(pattern: string): string; |
@@ -254,5 +254,6 @@ "use strict"; | ||
exports.CachingParser = CachingParser; | ||
exports.boundaryDelimiters = ',.'; | ||
function atBoundaryOnly(pattern) { | ||
return "(?:^|\\s)" + pattern + "(?=[\\s,.]|$)"; | ||
return "(?:^|\\s)" + pattern + "(?=[\\s" + exports.boundaryDelimiters + "]|$)"; | ||
} | ||
exports.atBoundaryOnly = atBoundaryOnly; |
305126
7770