|
1 | 1 | export type NestedArray<T> = T | NestedArray<T>[]; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * Currency format interface. |
| 5 | + * |
| 6 | + * Each property represents template string used by formatMoney. |
| 7 | + * Inside this template you can use these patterns: |
| 8 | + * - **%s** - Currency symbol |
| 9 | + * - **%v** - Amount |
| 10 | + * |
| 11 | + * **Examples**: |
| 12 | + * ```js |
| 13 | + * '%s %v' => '$ 1.00' |
| 14 | + * '%s (%v)' => '$ (1.00)' |
| 15 | + * '%s -- ' => '$ --' |
| 16 | + * ``` |
| 17 | + * |
| 18 | + * @typedef {Format} CurrencyFormat |
| 19 | + * @property {String} pos - Currency format for positive values |
| 20 | + * @property {String} [neg=pos] - Currency format for negative values |
| 21 | + * @property {String} [zero=pos] - Currency format for zero values |
| 22 | + * |
| 23 | + */ |
3 | 24 | export type CurrencyFormat = { |
4 | 25 | pos: string; // Currency format for positive values |
5 | 26 | neg?: string; // Currency format for negative values |
6 | 27 | zero?: string; // Currency format for zero values |
7 | 28 | }; |
8 | 29 |
|
| 30 | +/** |
| 31 | + * The library's settings configuration interface. |
| 32 | + * |
| 33 | + * @typedef {Object} Settings |
| 34 | + * @property {String} [symbol='$'] - Currency symbol |
| 35 | + * @property {String|CurrencyFormat} [format='%s%v'] - Controls output: %s = symbol, %v = value (can be object, see docs) |
| 36 | + * @property {String} [decimal='.'] - Decimal point separator |
| 37 | + * @property {String} [thousand=','] - Thousands separator |
| 38 | + * @property {Number} [precision=2] - Number of decimal places to round the amount to |
| 39 | + * @property {Number} [grouping=3] - Digit grouping (not implemented yet) |
| 40 | + * @property {Boolean} [stripZeros=false] - Strip insignificant zeros from decimal part |
| 41 | + * @property {Float} [fallback=0] - Value returned on unformat() failure |
| 42 | + * @property {Number} [round=0] - Decide round direction. |
| 43 | + */ |
9 | 44 | export type Settings = { |
10 | 45 | symbol?: string; // Currency symbol |
11 | 46 | format?: string | CurrencyFormat; // Controls output: %s = symbol, %v = value (can be object, see docs) |
|
0 commit comments