-
Notifications
You must be signed in to change notification settings - Fork 601
/
Copy pathcurrency-runtime.js
50 lines (40 loc) · 1.6 KB
/
currency-runtime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
define([
"./common/runtime-key",
"./common/validate/parameter-presence",
"./common/validate/parameter-type/number",
"./core-runtime",
"./currency/formatter-fn",
"./currency/name-format",
"./currency/to-parts-formatter-fn",
"./number-runtime"
], function( runtimeKey, validateParameterPresence, validateParameterTypeNumber, Globalize,
currencyFormatterFn, currencyNameFormat, currencyToPartsFormatterFn ) {
Globalize._currencyFormatterFn = currencyFormatterFn;
Globalize._currencyNameFormat = currencyNameFormat;
Globalize._currencyToPartsFormatterFn = currencyToPartsFormatterFn;
Globalize.currencyFormatter =
Globalize.prototype.currencyFormatter = function( currency, options ) {
options = options || {};
return Globalize[ runtimeKey( "currencyFormatter", this._locale, [ currency, options ] ) ];
};
Globalize.currencyToPartsFormatter =
Globalize.prototype.currencyToPartsFormatter = function( currency, options ) {
options = options || {};
return Globalize[
runtimeKey( "currencyToPartsFormatter", this._locale, [ currency, options ] )
];
};
Globalize.formatCurrency =
Globalize.prototype.formatCurrency = function( value, currency, options ) {
validateParameterPresence( value, "value" );
validateParameterTypeNumber( value, "value" );
return this.currencyFormatter( currency, options )( value );
};
Globalize.formatCurrencyToParts =
Globalize.prototype.formatCurrencyToParts = function( value, currency, options ) {
validateParameterPresence( value, "value" );
validateParameterTypeNumber( value, "value" );
return this.currencyToPartsFormatter( currency, options )( value );
};
return Globalize;
});