|
1 | 1 | import DECIMAL_PREFIX from './constants/DECIMAL_PREFIX.js';
|
2 | 2 | import REPETEND_PREFIX from './constants/REPETEND_PREFIX.js';
|
3 | 3 |
|
4 |
| -export default function _parse_fixed_point({_chr, reg, sub}) { |
5 |
| - return function (base, s) { |
6 |
| - const [integral, decimal] = s.split(DECIMAL_PREFIX); |
7 |
| - const [transient, repetend] = decimal.split(REPETEND_PREFIX); |
| 4 | +const _parse_fixed_point = ({_chr, reg, sub}) => (base, s) => { |
| 5 | + const [integral, decimal] = s.split(DECIMAL_PREFIX); |
| 6 | + const [transient, repetend] = decimal.split(REPETEND_PREFIX); |
8 | 7 |
|
9 |
| - const _integral = integral === '0' ? '' : integral; |
10 |
| - const _repetend = repetend || ''; |
| 8 | + const _integral = integral === '0' ? '' : integral; |
| 9 | + const _repetend = repetend || ''; |
11 | 10 |
|
12 |
| - const _denominator = |
13 |
| - (!_repetend |
14 |
| - ? _chr(1) |
15 |
| - : new Array(repetend.length + 1).join(_chr(base - 1))) + |
16 |
| - new Array(transient.length + 1).join(_chr(0)); |
| 11 | + const _denominator = |
| 12 | + (!_repetend |
| 13 | + ? _chr(1) |
| 14 | + : new Array(repetend.length + 1).join(_chr(base - 1))) + |
| 15 | + new Array(transient.length + 1).join(_chr(0)); |
17 | 16 |
|
18 |
| - const _big = _integral + transient + _repetend; |
19 |
| - const _small = _integral + transient || '0'; |
| 17 | + const _big = _integral + transient + _repetend; |
| 18 | + const _small = _integral + transient || '0'; |
20 | 19 |
|
21 |
| - const _bign = reg(_big, base); |
22 |
| - const _smalln = reg(_small, base); |
| 20 | + const _bign = reg(_big, base); |
| 21 | + const _smalln = reg(_small, base); |
23 | 22 |
|
24 |
| - const numerator = _repetend ? sub(_bign, _smalln) : _smalln; |
25 |
| - const denominator = reg(_denominator, base); |
| 23 | + const numerator = _repetend ? sub(_bign, _smalln) : _smalln; |
| 24 | + const denominator = reg(_denominator, base); |
26 | 25 |
|
27 |
| - return [numerator, denominator]; |
28 |
| - }; |
29 |
| -} |
| 26 | + return [numerator, denominator]; |
| 27 | +}; |
| 28 | + |
| 29 | +export default _parse_fixed_point; |
0 commit comments