Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
refactor: move formatters outside
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Feb 25, 2019
1 parent 0302560 commit 4be2807
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { format as d3Format } from 'd3-format';
import NumberFormatter from '../NumberFormatter';
import NumberFormats from '../NumberFormats';

const siFormatter = d3Format(`.3~s`);
const float2PointFormatter = d3Format(`.2~f`);
const float4PointFormatter = d3Format(`.4~f`);

export default function createSmartNumberFormatter(
config: {
description?: string;
Expand All @@ -13,10 +17,6 @@ export default function createSmartNumberFormatter(
} = {},
) {
const { description, signed = false, id, label } = config;
const siFormatter = d3Format(`.3~s`);
const float2PointFormatter = d3Format(`.2~f`);
const float4PointFormatter = d3Format(`.4~f`);

const getSign = signed ? (value: number) => (value > 0 ? '+' : '') : () => '';

function formatValue(value: number) {
Expand Down

0 comments on commit 4be2807

Please sign in to comment.