refactor: Move data structure functions into its own module
This commit is contained in:
Родитель
1cc809b2c9
Коммит
5d27536c90
|
@ -5,6 +5,7 @@ import ReactInterval from 'react-interval';
|
|||
// XXX: Create module that fetches ccov data + diff data
|
||||
import { coverageSummaryText } from './diffviewermeta';
|
||||
import * as FetchAPI from '../utils/fetch_data';
|
||||
import { arrayToMap, mapToArray } from '../utils/data';
|
||||
|
||||
const PENDING = 'Pending';
|
||||
|
||||
|
@ -54,18 +55,6 @@ const PollingStatus = ({ pollingEnabled }) => (
|
|||
</div>) : (null)
|
||||
);
|
||||
|
||||
const arrayToMap = (csets) => {
|
||||
const newCsets = {};
|
||||
csets.forEach((cset) => {
|
||||
newCsets[cset.node] = cset;
|
||||
});
|
||||
return newCsets;
|
||||
};
|
||||
|
||||
const mapToArray = csets => (
|
||||
Object.keys(csets).map(node => csets[node])
|
||||
);
|
||||
|
||||
const csetWithCcovData = async (cset) => {
|
||||
if (!cset.node) {
|
||||
throw Error(`No node for cset: ${cset}`);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export const arrayToMap = (csets) => {
|
||||
const newCsets = {};
|
||||
csets.forEach((cset) => {
|
||||
newCsets[cset.node] = cset;
|
||||
});
|
||||
return newCsets;
|
||||
};
|
||||
|
||||
export const mapToArray = csets => (
|
||||
Object.keys(csets).map(node => csets[node])
|
||||
);
|
Загрузка…
Ссылка в новой задаче