diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2020-07-14 15:24:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 15:24:17 -0400 |
commit | cde4dbb35132848ffece59ef9cfaccff32347124 (patch) | |
tree | cc7830968c6decde704c8cfb83c9185193dc698f /std/fmt/printf.ts | |
parent | 9eca71caa1674c31f9cc5d4e86c03f10b59e0a00 (diff) |
Use dprint for internal formatting (#6682)
Diffstat (limited to 'std/fmt/printf.ts')
-rw-r--r-- | std/fmt/printf.ts | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/std/fmt/printf.ts b/std/fmt/printf.ts index bf5feaaed..36b6dddb0 100644 --- a/std/fmt/printf.ts +++ b/std/fmt/printf.ts @@ -153,8 +153,9 @@ class Printf { break; case State.POSITIONAL: // either a verb or * only verb for now, TODO if (c === "*") { - const worp = - this.flags.precision === -1 ? WorP.WIDTH : WorP.PRECISION; + const worp = this.flags.precision === -1 + ? WorP.WIDTH + : WorP.PRECISION; this.handleWidthOrPrecisionRef(worp); this.state = State.PERCENT; break; @@ -503,8 +504,9 @@ class Printf { } let fractional = m[F.fractional]; - const precision = - this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION; + const precision = this.flags.precision !== -1 + ? this.flags.precision + : DEFAULT_PRECISION; fractional = this.roundFractionToPrecision(fractional, precision); let e = m[F.exponent]; @@ -553,8 +555,9 @@ class Printf { const dig = arr[0]; let fractional = arr[1]; - const precision = - this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION; + const precision = this.flags.precision !== -1 + ? this.flags.precision + : DEFAULT_PRECISION; fractional = this.roundFractionToPrecision(fractional, precision); return this.padNum(`${dig}.${fractional}`, n < 0); @@ -589,8 +592,9 @@ class Printf { // converted in the style of an f or F conversion specifier. // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html - let P = - this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION; + let P = this.flags.precision !== -1 + ? this.flags.precision + : DEFAULT_PRECISION; P = P === 0 ? 1 : P; const m = n.toExponential().match(FLOAT_REGEXP); @@ -650,15 +654,16 @@ class Printf { } default: throw new Error( - "currently only number and string are implemented for hex" + "currently only number and string are implemented for hex", ); } } fmtV(val: object): string { if (this.flags.sharp) { - const options = - this.flags.precision !== -1 ? { depth: this.flags.precision } : {}; + const options = this.flags.precision !== -1 + ? { depth: this.flags.precision } + : {}; return this.pad(Deno.inspect(val, options)); } else { const p = this.flags.precision; |