|
21 | 21 | // MODULES // |
22 | 22 |
|
23 | 23 | var isUppercase = require( '@stdlib/assert/is-uppercase' ); |
24 | | -var replace = require( '@stdlib/string/replace' ); |
25 | 24 | var isfinite = require( '@stdlib/math/base/assert/is-finite' ); |
26 | 25 | var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; |
27 | 26 |
|
28 | 27 | // NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies. |
29 | 28 | var abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math |
30 | 29 | var lowercase = String.prototype.toLowerCase; |
31 | 30 | var uppercase = String.prototype.toUpperCase; |
| 31 | +var replace = String.prototype.replace; |
32 | 32 |
|
33 | 33 |
|
34 | 34 | // VARIABLES // |
@@ -84,19 +84,19 @@ function formatDouble( token ) { |
84 | 84 | out = f.toPrecision( token.precision ); |
85 | 85 | } |
86 | 86 | if ( !token.alternate ) { |
87 | | - out = replace( out, RE_ZERO_BEFORE_EXP, '$1e' ); |
88 | | - out = replace( out, RE_PERIOD_ZERO_EXP, 'e'); |
89 | | - out = replace( out, RE_TRAILING_PERIOD_ZERO, '' ); |
| 87 | + out = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' ); |
| 88 | + out = replace.call( out, RE_PERIOD_ZERO_EXP, 'e'); |
| 89 | + out = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' ); |
90 | 90 | } |
91 | 91 | break; |
92 | 92 | default: |
93 | 93 | throw new Error( 'invalid double notation. Value: ' + token.specifier ); |
94 | 94 | } |
95 | | - out = replace( out, RE_EXP_POS_DIGITS, 'e+0$1' ); |
96 | | - out = replace( out, RE_EXP_NEG_DIGITS, 'e-0$1' ); |
| 95 | + out = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' ); |
| 96 | + out = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' ); |
97 | 97 | if ( token.alternate ) { |
98 | | - out = replace( out, RE_ONLY_DIGITS, '$1.' ); |
99 | | - out = replace( out, RE_DIGITS_BEFORE_EXP, '$1.e' ); |
| 98 | + out = replace.call( out, RE_ONLY_DIGITS, '$1.' ); |
| 99 | + out = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' ); |
100 | 100 | } |
101 | 101 | if ( f >= 0 && token.sign ) { |
102 | 102 | out = token.sign + out; |
|
0 commit comments