Skip to content

Commit

Permalink
refactor(utils): Rename metrics/get-metric-type to utils/metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Feb 29, 2020
1 parent 98e2769 commit f5ae1d8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/utils/src/metrics/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/utils/src/report/add-row-data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getDelta, formatDelta } from '../utils/delta';
import { formatPercentage } from '../utils/format';
import { getMetricType } from '../metrics/get-metric-type';
import { getMetricType } from '../utils/metrics';
import { getMetricChanged } from './get-metric-changed';

export const addRowData = (row, metricType) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { omit } from 'lodash';

import { METRIC_TYPE_FILE_SIZE } from '../../config/metrics';
import { getMetricType } from '../get-metric-type';
import { getMetricType } from '../metrics';

describe('getMetricType', () => {
test('should return metric', () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/utils/src/utils/delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export const getDelta = (baseline, current) => {
};
};

/**
* Format delta output
*
* @param {number} value Metric value
* @param {Function} formatter Metric type formatter
* @return {String} Delta output
*/
export const formatDelta = (value, formatter) => {
// eslint-disable-next-line no-nested-ternary
let sign = value > 0
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './delta';
export * from './date';
export * from './format';
export * from './metrics';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import { get } from 'lodash';

import METRICS, { METRIC_TYPE_NUMERIC, METRIC_TYPES } from '../config/metrics';

/**
* Get metric type data
*
* @param {String} key Metric key
* @param {String} [type] Default metric type
*
* @typedef {Object} Metric
* @property {String} label Metric label
* @property {String} type Metric type
* @property {Function} formatter Metric format handler
* @property {Boolean} biggerIsBetter Metric flag
*
* @return @Metric
*/
export const getMetricType = (key, type) => {
const metric = get(METRICS, key);

Expand Down

0 comments on commit f5ae1d8

Please sign in to comment.